comparison dwtx/dwtxhelper/mangoicu/UCalendar.d @ 91:11e8159caf7a

make the mango icu fork work.
author Frank Benoit <benoit@tionex.de>
date Mon, 07 Jul 2008 15:53:07 +0200
parents 040da1cb0d76
children f05207c07a98
comparison
equal deleted inserted replaced
90:7ffeace6c47f 91:11e8159caf7a
80 All trademarks and registered trademarks mentioned herein are the 80 All trademarks and registered trademarks mentioned herein are the
81 property of their respective owners. 81 property of their respective owners.
82 82
83 *******************************************************************************/ 83 *******************************************************************************/
84 84
85 module dwtx.dwthelper.mangoicu.UCalendar; 85 module dwtx.dwtxhelper.mangoicu.UCalendar;
86 86
87 private import dwtx.dwthelper.mangoicu.ICU, 87 private import dwtx.dwtxhelper.mangoicu.ICU,
88 dwtx.dwthelper.mangoicu.UString; 88 dwtx.dwtxhelper.mangoicu.UString;
89 89
90 public import dwtx.dwthelper.mangoicu.ULocale, 90 public import dwtx.dwtxhelper.mangoicu.ULocale,
91 dwtx.dwthelper.mangoicu.UTimeZone; 91 dwtx.dwtxhelper.mangoicu.UTimeZone;
92 92
93 /******************************************************************************* 93 /*******************************************************************************
94 94
95 UCalendar is used for converting between a UDate object and 95 UCalendar is used for converting between a UDate object and
96 a set of integer fields such as Year, Month, Day, 96 a set of integer fields such as Year, Month, Day,
242 242
243 ***********************************************************************/ 243 ***********************************************************************/
244 244
245 this (inout UTimeZone zone, inout ULocale locale, Type type = Type.Traditional) 245 this (inout UTimeZone zone, inout ULocale locale, Type type = Type.Traditional)
246 { 246 {
247 Error e; 247 UErrorCode e;
248 248
249 handle = ucal_open (zone.name.ptr, zone.name.length, toString(locale.name), type, e); 249 handle = ucal_open (zone.name.ptr, zone.name.length, toString(locale.name), type, e);
250 testError (e, "failed to open calendar"); 250 testError (e, "failed to open calendar");
251 } 251 }
252 252
278 278
279 ***********************************************************************/ 279 ***********************************************************************/
280 280
281 void setTimeZone (inout UTimeZone zone) 281 void setTimeZone (inout UTimeZone zone)
282 { 282 {
283 Error e; 283 UErrorCode e;
284 284
285 ucal_setTimeZone (handle, zone.name.ptr, zone.name.length, e); 285 ucal_setTimeZone (handle, zone.name.ptr, zone.name.length, e);
286 testError (e, "failed to set calendar time zone"); 286 testError (e, "failed to set calendar time zone");
287 } 287 }
288 288
292 292
293 ***********************************************************************/ 293 ***********************************************************************/
294 294
295 void getTimeZoneName (UString s, inout ULocale locale, DisplayNameType type=DisplayNameType.Standard) 295 void getTimeZoneName (UString s, inout ULocale locale, DisplayNameType type=DisplayNameType.Standard)
296 { 296 {
297 uint format (wchar* dst, uint length, inout ICU.Error e) 297 uint format (wchar* dst, uint length, inout ICU.UErrorCode e)
298 { 298 {
299 return ucal_getTimeZoneDisplayName (handle, type, toString(locale.name), dst, length, e); 299 return ucal_getTimeZoneDisplayName (handle, type, toString(locale.name), dst, length, e);
300 } 300 }
301 301
302 s.format (&format, "failed to get time zone name"); 302 s.format (&format, "failed to get time zone name");
309 309
310 ***********************************************************************/ 310 ***********************************************************************/
311 311
312 bool inDaylightTime () 312 bool inDaylightTime ()
313 { 313 {
314 Error e; 314 UErrorCode e;
315 315
316 auto x = ucal_inDaylightTime (handle, e); 316 auto x = ucal_inDaylightTime (handle, e);
317 testError (e, "failed to test calendar daylight time"); 317 testError (e, "failed to test calendar daylight time");
318 return x != 0; 318 return x != 0;
319 } 319 }
336 336
337 ***********************************************************************/ 337 ***********************************************************************/
338 338
339 UDate getMillis () 339 UDate getMillis ()
340 { 340 {
341 Error e; 341 UErrorCode e;
342 342
343 auto x = ucal_getMillis (handle, e); 343 auto x = ucal_getMillis (handle, e);
344 testError (e, "failed to get time"); 344 testError (e, "failed to get time");
345 return x; 345 return x;
346 } 346 }
352 352
353 ***********************************************************************/ 353 ***********************************************************************/
354 354
355 void setMillis (UDate date) 355 void setMillis (UDate date)
356 { 356 {
357 Error e; 357 UErrorCode e;
358 358
359 ucal_setMillis (handle, date, e); 359 ucal_setMillis (handle, date, e);
360 testError (e, "failed to set time"); 360 testError (e, "failed to set time");
361 } 361 }
362 362
366 366
367 ***********************************************************************/ 367 ***********************************************************************/
368 368
369 void setDate (uint year, Months month, uint date) 369 void setDate (uint year, Months month, uint date)
370 { 370 {
371 Error e; 371 UErrorCode e;
372 372
373 ucal_setDate (handle, year, month, date, e); 373 ucal_setDate (handle, year, month, date, e);
374 testError (e, "failed to set date"); 374 testError (e, "failed to set date");
375 } 375 }
376 376
380 380
381 ***********************************************************************/ 381 ***********************************************************************/
382 382
383 void setDateTime (uint year, Months month, uint date, uint hour, uint minute, uint second) 383 void setDateTime (uint year, Months month, uint date, uint hour, uint minute, uint second)
384 { 384 {
385 Error e; 385 UErrorCode e;
386 386
387 ucal_setDateTime (handle, year, month, date, hour, minute, second, e); 387 ucal_setDateTime (handle, year, month, date, hour, minute, second, e);
388 testError (e, "failed to set date/time"); 388 testError (e, "failed to set date/time");
389 } 389 }
390 390
442 442
443 ***********************************************************************/ 443 ***********************************************************************/
444 444
445 void add (DateFields field, uint amount) 445 void add (DateFields field, uint amount)
446 { 446 {
447 Error e; 447 UErrorCode e;
448 448
449 ucal_add (handle, field, amount, e); 449 ucal_add (handle, field, amount, e);
450 testError (e, "failed to add to calendar"); 450 testError (e, "failed to add to calendar");
451 } 451 }
452 452
457 457
458 ***********************************************************************/ 458 ***********************************************************************/
459 459
460 void roll (DateFields field, uint amount) 460 void roll (DateFields field, uint amount)
461 { 461 {
462 Error e; 462 UErrorCode e;
463 463
464 ucal_roll (handle, field, amount, e); 464 ucal_roll (handle, field, amount, e);
465 testError (e, "failed to roll calendar"); 465 testError (e, "failed to roll calendar");
466 } 466 }
467 467
471 471
472 ***********************************************************************/ 472 ***********************************************************************/
473 473
474 uint get (DateFields field) 474 uint get (DateFields field)
475 { 475 {
476 Error e; 476 UErrorCode e;
477 477
478 auto x = ucal_get (handle, field, e); 478 auto x = ucal_get (handle, field, e);
479 testError (e, "failed to get calendar field"); 479 testError (e, "failed to get calendar field");
480 return x; 480 return x;
481 } 481 }
531 531
532 ***********************************************************************/ 532 ***********************************************************************/
533 533
534 uint getLimit (DateFields field, Limit type) 534 uint getLimit (DateFields field, Limit type)
535 { 535 {
536 Error e; 536 UErrorCode e;
537 537
538 auto x = ucal_getLimit (handle, field, type, e); 538 auto x = ucal_getLimit (handle, field, type, e);
539 testError (e, "failed to get calendar limit"); 539 testError (e, "failed to get calendar limit");
540 return x; 540 return x;
541 } 541 }
591 591
592 ***********************************************************************/ 592 ***********************************************************************/
593 593
594 private static extern (C) 594 private static extern (C)
595 { 595 {
596 Handle function (wchar*, uint, char*, Type, inout Error) ucal_open; 596 Handle function (wchar*, uint, char*, Type, inout UErrorCode) ucal_open;
597 void function (Handle) ucal_close; 597 void function (Handle) ucal_close;
598 UDate function () ucal_getNow; 598 UDate function () ucal_getNow;
599 UDate function (Handle, inout Error) ucal_getMillis; 599 UDate function (Handle, inout UErrorCode) ucal_getMillis;
600 void function (Handle, UDate, inout Error) ucal_setMillis; 600 void function (Handle, UDate, inout UErrorCode) ucal_setMillis;
601 void function (Handle, uint, uint, uint, inout Error) ucal_setDate; 601 void function (Handle, uint, uint, uint, inout UErrorCode) ucal_setDate;
602 void function (Handle, uint, uint, uint, uint, uint, uint, inout Error) ucal_setDateTime; 602 void function (Handle, uint, uint, uint, uint, uint, uint, inout UErrorCode) ucal_setDateTime;
603 byte function (Handle, Handle) ucal_equivalentTo; 603 byte function (Handle, Handle) ucal_equivalentTo;
604 void function (Handle, uint, uint, inout Error) ucal_add; 604 void function (Handle, uint, uint, inout UErrorCode) ucal_add;
605 void function (Handle, uint, uint, inout Error) ucal_roll; 605 void function (Handle, uint, uint, inout UErrorCode) ucal_roll;
606 uint function (Handle, uint, inout Error) ucal_get; 606 uint function (Handle, uint, inout UErrorCode) ucal_get;
607 void function (Handle, uint, uint) ucal_set; 607 void function (Handle, uint, uint) ucal_set;
608 byte function (Handle, uint) ucal_isSet; 608 byte function (Handle, uint) ucal_isSet;
609 void function (Handle, uint) ucal_clearField; 609 void function (Handle, uint) ucal_clearField;
610 void function (Handle) ucal_clear; 610 void function (Handle) ucal_clear;
611 uint function (Handle, uint, uint, inout Error) ucal_getLimit; 611 uint function (Handle, uint, uint, inout UErrorCode) ucal_getLimit;
612 void function (Handle, wchar*, uint, inout Error) ucal_setTimeZone; 612 void function (Handle, wchar*, uint, inout UErrorCode) ucal_setTimeZone;
613 byte function (Handle, uint) ucal_inDaylightTime; 613 byte function (Handle, uint) ucal_inDaylightTime;
614 uint function (Handle, uint) ucal_getAttribute; 614 uint function (Handle, uint) ucal_getAttribute;
615 void function (Handle, uint, uint) ucal_setAttribute; 615 void function (Handle, uint, uint) ucal_setAttribute;
616 uint function (Handle, uint, char*, wchar*, uint, inout Error) ucal_getTimeZoneDisplayName; 616 uint function (Handle, uint, char*, wchar*, uint, inout UErrorCode) ucal_getTimeZoneDisplayName;
617 } 617 }
618 618
619 /*********************************************************************** 619 /***********************************************************************
620 620
621 ***********************************************************************/ 621 ***********************************************************************/