00001
00002
00003
00004
00005
00006
00007
00008 #ifndef UDAT_H
00009 #define UDAT_H
00010
00011 #include "unicode/utypes.h"
00012
00013 #if !UCONFIG_NO_FORMATTING
00014
00015 #include "unicode/localpointer.h"
00016 #include "unicode/ucal.h"
00017 #include "unicode/unum.h"
00018 #include "unicode/udisplaycontext.h"
00019 #include "unicode/ufieldpositer.h"
00151 typedef void* UDateFormat;
00152
00156 typedef enum UDateFormatStyle {
00158 UDAT_FULL,
00160 UDAT_LONG,
00162 UDAT_MEDIUM,
00164 UDAT_SHORT,
00166 UDAT_DEFAULT = UDAT_MEDIUM,
00167
00169 UDAT_RELATIVE = (1 << 7),
00170
00171 UDAT_FULL_RELATIVE = UDAT_FULL | UDAT_RELATIVE,
00172
00173 UDAT_LONG_RELATIVE = UDAT_LONG | UDAT_RELATIVE,
00174
00175 UDAT_MEDIUM_RELATIVE = UDAT_MEDIUM | UDAT_RELATIVE,
00176
00177 UDAT_SHORT_RELATIVE = UDAT_SHORT | UDAT_RELATIVE,
00178
00179
00181 UDAT_NONE = -1,
00182
00188 UDAT_PATTERN = -2,
00189
00190 #ifndef U_HIDE_INTERNAL_API
00192 UDAT_IGNORE = UDAT_PATTERN
00193 #endif
00194 } UDateFormatStyle;
00195
00196
00197
00202 #define UDAT_YEAR "y"
00203
00207 #define UDAT_QUARTER "QQQQ"
00208
00212 #define UDAT_ABBR_QUARTER "QQQ"
00213
00217 #define UDAT_YEAR_QUARTER "yQQQQ"
00218
00222 #define UDAT_YEAR_ABBR_QUARTER "yQQQ"
00223
00227 #define UDAT_MONTH "MMMM"
00228
00232 #define UDAT_ABBR_MONTH "MMM"
00233
00237 #define UDAT_NUM_MONTH "M"
00238
00242 #define UDAT_YEAR_MONTH "yMMMM"
00243
00247 #define UDAT_YEAR_ABBR_MONTH "yMMM"
00248
00252 #define UDAT_YEAR_NUM_MONTH "yM"
00253
00257 #define UDAT_DAY "d"
00258
00263 #define UDAT_YEAR_MONTH_DAY "yMMMMd"
00264
00269 #define UDAT_YEAR_ABBR_MONTH_DAY "yMMMd"
00270
00275 #define UDAT_YEAR_NUM_MONTH_DAY "yMd"
00276
00280 #define UDAT_WEEKDAY "EEEE"
00281
00285 #define UDAT_ABBR_WEEKDAY "E"
00286
00291 #define UDAT_YEAR_MONTH_WEEKDAY_DAY "yMMMMEEEEd"
00292
00297 #define UDAT_YEAR_ABBR_MONTH_WEEKDAY_DAY "yMMMEd"
00298
00303 #define UDAT_YEAR_NUM_MONTH_WEEKDAY_DAY "yMEd"
00304
00309 #define UDAT_MONTH_DAY "MMMMd"
00310
00315 #define UDAT_ABBR_MONTH_DAY "MMMd"
00316
00321 #define UDAT_NUM_MONTH_DAY "Md"
00322
00327 #define UDAT_MONTH_WEEKDAY_DAY "MMMMEEEEd"
00328
00333 #define UDAT_ABBR_MONTH_WEEKDAY_DAY "MMMEd"
00334
00339 #define UDAT_NUM_MONTH_WEEKDAY_DAY "MEd"
00340
00341
00342
00347 #define UDAT_HOUR "j"
00348
00352 #define UDAT_HOUR24 "H"
00353
00357 #define UDAT_MINUTE "m"
00358
00363 #define UDAT_HOUR_MINUTE "jm"
00364
00369 #define UDAT_HOUR24_MINUTE "Hm"
00370
00374 #define UDAT_SECOND "s"
00375
00381 #define UDAT_HOUR_MINUTE_SECOND "jms"
00382
00388 #define UDAT_HOUR24_MINUTE_SECOND "Hms"
00389
00394 #define UDAT_MINUTE_SECOND "ms"
00395
00396
00397
00405 #define UDAT_LOCATION_TZ "VVVV"
00406
00413 #define UDAT_GENERIC_TZ "vvvv"
00414
00421 #define UDAT_ABBR_GENERIC_TZ "v"
00422
00429 #define UDAT_SPECIFIC_TZ "zzzz"
00430
00437 #define UDAT_ABBR_SPECIFIC_TZ "z"
00438
00445 #define UDAT_ABBR_UTC_TZ "ZZZZ"
00446
00447
00448
00449 #ifndef U_HIDE_DEPRECATED_API
00450
00454 #define UDAT_STANDALONE_MONTH "LLLL"
00455
00459 #define UDAT_ABBR_STANDALONE_MONTH "LLL"
00460
00465 #define UDAT_HOUR_MINUTE_GENERIC_TZ "jmv"
00466
00470 #define UDAT_HOUR_MINUTE_TZ "jmz"
00471
00475 #define UDAT_HOUR_GENERIC_TZ "jv"
00476
00480 #define UDAT_HOUR_TZ "jz"
00481 #endif
00482
00488 typedef enum UDateFormatField {
00494 UDAT_ERA_FIELD = 0,
00495
00501 UDAT_YEAR_FIELD = 1,
00502
00508 UDAT_MONTH_FIELD = 2,
00509
00515 UDAT_DATE_FIELD = 3,
00516
00524 UDAT_HOUR_OF_DAY1_FIELD = 4,
00525
00533 UDAT_HOUR_OF_DAY0_FIELD = 5,
00534
00540 UDAT_MINUTE_FIELD = 6,
00541
00547 UDAT_SECOND_FIELD = 7,
00548
00562 UDAT_FRACTIONAL_SECOND_FIELD = 8,
00563
00569 UDAT_DAY_OF_WEEK_FIELD = 9,
00570
00576 UDAT_DAY_OF_YEAR_FIELD = 10,
00577
00583 UDAT_DAY_OF_WEEK_IN_MONTH_FIELD = 11,
00584
00590 UDAT_WEEK_OF_YEAR_FIELD = 12,
00591
00597 UDAT_WEEK_OF_MONTH_FIELD = 13,
00598
00604 UDAT_AM_PM_FIELD = 14,
00605
00613 UDAT_HOUR1_FIELD = 15,
00614
00622 UDAT_HOUR0_FIELD = 16,
00623
00630 UDAT_TIMEZONE_FIELD = 17,
00631
00637 UDAT_YEAR_WOY_FIELD = 18,
00638
00644 UDAT_DOW_LOCAL_FIELD = 19,
00645
00651 UDAT_EXTENDED_YEAR_FIELD = 20,
00652
00658 UDAT_JULIAN_DAY_FIELD = 21,
00659
00665 UDAT_MILLISECONDS_IN_DAY_FIELD = 22,
00666
00673 UDAT_TIMEZONE_RFC_FIELD = 23,
00674
00680 UDAT_TIMEZONE_GENERIC_FIELD = 24,
00687 UDAT_STANDALONE_DAY_FIELD = 25,
00688
00695 UDAT_STANDALONE_MONTH_FIELD = 26,
00696
00704 UDAT_QUARTER_FIELD = 27,
00705
00713 UDAT_STANDALONE_QUARTER_FIELD = 28,
00714
00720 UDAT_TIMEZONE_SPECIAL_FIELD = 29,
00721
00729 UDAT_YEAR_NAME_FIELD = 30,
00730
00737 UDAT_TIMEZONE_LOCALIZED_GMT_OFFSET_FIELD = 31,
00738
00745 UDAT_TIMEZONE_ISO_FIELD = 32,
00746
00753 UDAT_TIMEZONE_ISO_LOCAL_FIELD = 33,
00754
00755 #ifndef U_HIDE_INTERNAL_API
00756
00761 UDAT_RELATED_YEAR_FIELD = 34,
00762 #endif
00763
00764 #ifndef U_HIDE_DRAFT_API
00765
00771 UDAT_AM_PM_MIDNIGHT_NOON_FIELD = 35,
00772
00773
00774
00775
00776
00777 UDAT_FLEXIBLE_DAY_PERIOD_FIELD = 36,
00778 #endif
00779
00780 #ifndef U_HIDE_INTERNAL_API
00781
00787 UDAT_TIME_SEPARATOR_FIELD = 37,
00788 #endif
00789
00798 UDAT_FIELD_COUNT = 38
00799
00800 } UDateFormatField;
00801
00802
00803 #ifndef U_HIDE_INTERNAL_API
00804
00809 #define UDAT_HAS_PATTERN_CHAR_FOR_TIME_SEPARATOR 0
00810 #endif
00811
00812
00821 U_STABLE UCalendarDateFields U_EXPORT2
00822 udat_toCalendarDateField(UDateFormatField field);
00823
00824
00853 U_STABLE UDateFormat* U_EXPORT2
00854 udat_open(UDateFormatStyle timeStyle,
00855 UDateFormatStyle dateStyle,
00856 const char *locale,
00857 const UChar *tzID,
00858 int32_t tzIDLength,
00859 const UChar *pattern,
00860 int32_t patternLength,
00861 UErrorCode *status);
00862
00863
00870 U_STABLE void U_EXPORT2
00871 udat_close(UDateFormat* format);
00872
00873
00879 typedef enum UDateFormatBooleanAttribute {
00884 UDAT_PARSE_ALLOW_WHITESPACE = 0,
00890 UDAT_PARSE_ALLOW_NUMERIC = 1,
00891 #ifndef U_HIDE_DRAFT_API
00892
00897 UDAT_PARSE_PARTIAL_LITERAL_MATCH = 2,
00903 UDAT_PARSE_MULTIPLE_PATTERNS_FOR_MATCH = 3,
00904 #endif
00905
00909 UDAT_BOOLEAN_ATTRIBUTE_COUNT = 4
00910 } UDateFormatBooleanAttribute;
00911
00922 U_STABLE UBool U_EXPORT2
00923 udat_getBooleanAttribute(const UDateFormat* fmt, UDateFormatBooleanAttribute attr, UErrorCode* status);
00924
00935 U_STABLE void U_EXPORT2
00936 udat_setBooleanAttribute(UDateFormat *fmt, UDateFormatBooleanAttribute attr, UBool newValue, UErrorCode* status);
00937
00938
00939
00940 #if U_SHOW_CPLUSPLUS_API
00941
00942 U_NAMESPACE_BEGIN
00943
00953 U_DEFINE_LOCAL_OPEN_POINTER(LocalUDateFormatPointer, UDateFormat, udat_close);
00954
00955 U_NAMESPACE_END
00956
00957 #endif
00958
00967 U_STABLE UDateFormat* U_EXPORT2
00968 udat_clone(const UDateFormat *fmt,
00969 UErrorCode *status);
00970
00989 U_STABLE int32_t U_EXPORT2
00990 udat_format( const UDateFormat* format,
00991 UDate dateToFormat,
00992 UChar* result,
00993 int32_t resultLength,
00994 UFieldPosition* position,
00995 UErrorCode* status);
00996
01019 U_STABLE int32_t U_EXPORT2
01020 udat_formatCalendar( const UDateFormat* format,
01021 UCalendar* calendar,
01022 UChar* result,
01023 int32_t capacity,
01024 UFieldPosition* position,
01025 UErrorCode* status);
01026
01054 U_STABLE int32_t U_EXPORT2
01055 udat_formatForFields( const UDateFormat* format,
01056 UDate dateToFormat,
01057 UChar* result,
01058 int32_t resultLength,
01059 UFieldPositionIterator* fpositer,
01060 UErrorCode* status);
01061
01092 U_STABLE int32_t U_EXPORT2
01093 udat_formatCalendarForFields( const UDateFormat* format,
01094 UCalendar* calendar,
01095 UChar* result,
01096 int32_t capacity,
01097 UFieldPositionIterator* fpositer,
01098 UErrorCode* status);
01099
01100
01126 U_STABLE UDate U_EXPORT2
01127 udat_parse(const UDateFormat* format,
01128 const UChar* text,
01129 int32_t textLength,
01130 int32_t *parsePos,
01131 UErrorCode *status);
01132
01154 U_STABLE void U_EXPORT2
01155 udat_parseCalendar(const UDateFormat* format,
01156 UCalendar* calendar,
01157 const UChar* text,
01158 int32_t textLength,
01159 int32_t *parsePos,
01160 UErrorCode *status);
01161
01171 U_STABLE UBool U_EXPORT2
01172 udat_isLenient(const UDateFormat* fmt);
01173
01183 U_STABLE void U_EXPORT2
01184 udat_setLenient( UDateFormat* fmt,
01185 UBool isLenient);
01186
01196 U_STABLE const UCalendar* U_EXPORT2
01197 udat_getCalendar(const UDateFormat* fmt);
01198
01208 U_STABLE void U_EXPORT2
01209 udat_setCalendar( UDateFormat* fmt,
01210 const UCalendar* calendarToSet);
01211
01221 U_STABLE const UNumberFormat* U_EXPORT2
01222 udat_getNumberFormat(const UDateFormat* fmt);
01223
01233 U_STABLE const UNumberFormat* U_EXPORT2
01234 udat_getNumberFormatForField(const UDateFormat* fmt, UChar field);
01235
01251 U_STABLE void U_EXPORT2
01252 udat_adoptNumberFormatForFields( UDateFormat* fmt,
01253 const UChar* fields,
01254 UNumberFormat* numberFormatToSet,
01255 UErrorCode* status);
01268 U_STABLE void U_EXPORT2
01269 udat_setNumberFormat( UDateFormat* fmt,
01270 const UNumberFormat* numberFormatToSet);
01280 U_STABLE void U_EXPORT2
01281 udat_adoptNumberFormat( UDateFormat* fmt,
01282 UNumberFormat* numberFormatToAdopt);
01292 U_STABLE const char* U_EXPORT2
01293 udat_getAvailable(int32_t localeIndex);
01294
01303 U_STABLE int32_t U_EXPORT2
01304 udat_countAvailable(void);
01305
01316 U_STABLE UDate U_EXPORT2
01317 udat_get2DigitYearStart( const UDateFormat *fmt,
01318 UErrorCode *status);
01319
01330 U_STABLE void U_EXPORT2
01331 udat_set2DigitYearStart( UDateFormat *fmt,
01332 UDate d,
01333 UErrorCode *status);
01334
01347 U_STABLE int32_t U_EXPORT2
01348 udat_toPattern( const UDateFormat *fmt,
01349 UBool localized,
01350 UChar *result,
01351 int32_t resultLength,
01352 UErrorCode *status);
01353
01364 U_STABLE void U_EXPORT2
01365 udat_applyPattern( UDateFormat *format,
01366 UBool localized,
01367 const UChar *pattern,
01368 int32_t patternLength);
01369
01374 typedef enum UDateFormatSymbolType {
01376 UDAT_ERAS,
01378 UDAT_MONTHS,
01380 UDAT_SHORT_MONTHS,
01382 UDAT_WEEKDAYS,
01387 UDAT_SHORT_WEEKDAYS,
01389 UDAT_AM_PMS,
01391 UDAT_LOCALIZED_CHARS,
01393 UDAT_ERA_NAMES,
01395 UDAT_NARROW_MONTHS,
01397 UDAT_NARROW_WEEKDAYS,
01399 UDAT_STANDALONE_MONTHS,
01400 UDAT_STANDALONE_SHORT_MONTHS,
01401 UDAT_STANDALONE_NARROW_MONTHS,
01403 UDAT_STANDALONE_WEEKDAYS,
01408 UDAT_STANDALONE_SHORT_WEEKDAYS,
01410 UDAT_STANDALONE_NARROW_WEEKDAYS,
01412 UDAT_QUARTERS,
01414 UDAT_SHORT_QUARTERS,
01416 UDAT_STANDALONE_QUARTERS,
01417 UDAT_STANDALONE_SHORT_QUARTERS,
01425 UDAT_SHORTER_WEEKDAYS,
01430 UDAT_STANDALONE_SHORTER_WEEKDAYS,
01436 UDAT_CYCLIC_YEARS_WIDE,
01441 UDAT_CYCLIC_YEARS_ABBREVIATED,
01447 UDAT_CYCLIC_YEARS_NARROW,
01453 UDAT_ZODIAC_NAMES_WIDE,
01458 UDAT_ZODIAC_NAMES_ABBREVIATED,
01464 UDAT_ZODIAC_NAMES_NARROW
01465 } UDateFormatSymbolType;
01466
01467 struct UDateFormatSymbols;
01472 typedef struct UDateFormatSymbols UDateFormatSymbols;
01473
01490 U_STABLE int32_t U_EXPORT2
01491 udat_getSymbols(const UDateFormat *fmt,
01492 UDateFormatSymbolType type,
01493 int32_t symbolIndex,
01494 UChar *result,
01495 int32_t resultLength,
01496 UErrorCode *status);
01497
01510 U_STABLE int32_t U_EXPORT2
01511 udat_countSymbols( const UDateFormat *fmt,
01512 UDateFormatSymbolType type);
01513
01529 U_STABLE void U_EXPORT2
01530 udat_setSymbols( UDateFormat *format,
01531 UDateFormatSymbolType type,
01532 int32_t symbolIndex,
01533 UChar *value,
01534 int32_t valueLength,
01535 UErrorCode *status);
01536
01546 U_STABLE const char* U_EXPORT2
01547 udat_getLocaleByType(const UDateFormat *fmt,
01548 ULocDataLocaleType type,
01549 UErrorCode* status);
01550
01559 U_DRAFT void U_EXPORT2
01560 udat_setContext(UDateFormat* fmt, UDisplayContext value, UErrorCode* status);
01561
01571 U_STABLE UDisplayContext U_EXPORT2
01572 udat_getContext(const UDateFormat* fmt, UDisplayContextType type, UErrorCode* status);
01573
01574 #ifndef U_HIDE_INTERNAL_API
01575
01586 U_INTERNAL int32_t U_EXPORT2
01587 udat_toPatternRelativeDate(const UDateFormat *fmt,
01588 UChar *result,
01589 int32_t resultLength,
01590 UErrorCode *status);
01591
01603 U_INTERNAL int32_t U_EXPORT2
01604 udat_toPatternRelativeTime(const UDateFormat *fmt,
01605 UChar *result,
01606 int32_t resultLength,
01607 UErrorCode *status);
01608
01621 U_INTERNAL void U_EXPORT2
01622 udat_applyPatternRelative(UDateFormat *format,
01623 const UChar *datePattern,
01624 int32_t datePatternLength,
01625 const UChar *timePattern,
01626 int32_t timePatternLength,
01627 UErrorCode *status);
01628
01633 typedef UDateFormat* (U_EXPORT2 *UDateFormatOpener) (UDateFormatStyle timeStyle,
01634 UDateFormatStyle dateStyle,
01635 const char *locale,
01636 const UChar *tzID,
01637 int32_t tzIDLength,
01638 const UChar *pattern,
01639 int32_t patternLength,
01640 UErrorCode *status);
01641
01646 U_INTERNAL void U_EXPORT2
01647 udat_registerOpener(UDateFormatOpener opener, UErrorCode *status);
01648
01653 U_INTERNAL UDateFormatOpener U_EXPORT2
01654 udat_unregisterOpener(UDateFormatOpener opener, UErrorCode *status);
01655 #endif
01656
01657
01658 #endif
01659
01660 #endif