|
ICU 73.2
73.2
|
00001 // © 2016 and later: Unicode, Inc. and others. 00002 // License & terms of use: http://www.unicode.org/copyright.html 00003 /* 00004 ******************************************************************************* 00005 * Copyright (C) 1996-2016, International Business Machines 00006 * Corporation and others. All Rights Reserved. 00007 ******************************************************************************* 00008 */ 00009 00010 #ifndef UDAT_H 00011 #define UDAT_H 00012 00013 #include "unicode/utypes.h" 00014 00015 #if !UCONFIG_NO_FORMATTING 00016 00017 #include "unicode/ucal.h" 00018 #include "unicode/unum.h" 00019 #include "unicode/udisplaycontext.h" 00020 #include "unicode/ufieldpositer.h" 00021 00022 #if U_SHOW_CPLUSPLUS_API 00023 #include "unicode/localpointer.h" 00024 #endif // U_SHOW_CPLUSPLUS_API 00025 00157 typedef void* UDateFormat; 00158 00162 typedef enum UDateFormatStyle { 00164 UDAT_FULL, 00166 UDAT_LONG, 00168 UDAT_MEDIUM, 00170 UDAT_SHORT, 00172 UDAT_DEFAULT = UDAT_MEDIUM, 00173 00175 UDAT_RELATIVE = (1 << 7), 00176 00177 UDAT_FULL_RELATIVE = UDAT_FULL | UDAT_RELATIVE, 00178 00179 UDAT_LONG_RELATIVE = UDAT_LONG | UDAT_RELATIVE, 00180 00181 UDAT_MEDIUM_RELATIVE = UDAT_MEDIUM | UDAT_RELATIVE, 00182 00183 UDAT_SHORT_RELATIVE = UDAT_SHORT | UDAT_RELATIVE, 00184 00185 00187 UDAT_NONE = -1, 00188 00194 UDAT_PATTERN = -2, 00195 00196 #ifndef U_HIDE_INTERNAL_API 00198 UDAT_IGNORE = UDAT_PATTERN 00199 #endif /* U_HIDE_INTERNAL_API */ 00200 } UDateFormatStyle; 00201 00202 /* Skeletons for dates. */ 00203 00208 #define UDAT_YEAR "y" 00209 00213 #define UDAT_QUARTER "QQQQ" 00214 00218 #define UDAT_ABBR_QUARTER "QQQ" 00219 00223 #define UDAT_YEAR_QUARTER "yQQQQ" 00224 00228 #define UDAT_YEAR_ABBR_QUARTER "yQQQ" 00229 00233 #define UDAT_MONTH "MMMM" 00234 00238 #define UDAT_ABBR_MONTH "MMM" 00239 00243 #define UDAT_NUM_MONTH "M" 00244 00248 #define UDAT_YEAR_MONTH "yMMMM" 00249 00253 #define UDAT_YEAR_ABBR_MONTH "yMMM" 00254 00258 #define UDAT_YEAR_NUM_MONTH "yM" 00259 00263 #define UDAT_DAY "d" 00264 00269 #define UDAT_YEAR_MONTH_DAY "yMMMMd" 00270 00275 #define UDAT_YEAR_ABBR_MONTH_DAY "yMMMd" 00276 00281 #define UDAT_YEAR_NUM_MONTH_DAY "yMd" 00282 00286 #define UDAT_WEEKDAY "EEEE" 00287 00291 #define UDAT_ABBR_WEEKDAY "E" 00292 00297 #define UDAT_YEAR_MONTH_WEEKDAY_DAY "yMMMMEEEEd" 00298 00303 #define UDAT_YEAR_ABBR_MONTH_WEEKDAY_DAY "yMMMEd" 00304 00309 #define UDAT_YEAR_NUM_MONTH_WEEKDAY_DAY "yMEd" 00310 00315 #define UDAT_MONTH_DAY "MMMMd" 00316 00321 #define UDAT_ABBR_MONTH_DAY "MMMd" 00322 00327 #define UDAT_NUM_MONTH_DAY "Md" 00328 00333 #define UDAT_MONTH_WEEKDAY_DAY "MMMMEEEEd" 00334 00339 #define UDAT_ABBR_MONTH_WEEKDAY_DAY "MMMEd" 00340 00345 #define UDAT_NUM_MONTH_WEEKDAY_DAY "MEd" 00346 00347 /* Skeletons for times. */ 00348 00353 #define UDAT_HOUR "j" 00354 00358 #define UDAT_HOUR24 "H" 00359 00363 #define UDAT_MINUTE "m" 00364 00369 #define UDAT_HOUR_MINUTE "jm" 00370 00375 #define UDAT_HOUR24_MINUTE "Hm" 00376 00380 #define UDAT_SECOND "s" 00381 00387 #define UDAT_HOUR_MINUTE_SECOND "jms" 00388 00394 #define UDAT_HOUR24_MINUTE_SECOND "Hms" 00395 00400 #define UDAT_MINUTE_SECOND "ms" 00401 00402 /* Skeletons for time zones. */ 00403 00411 #define UDAT_LOCATION_TZ "VVVV" 00412 00419 #define UDAT_GENERIC_TZ "vvvv" 00420 00427 #define UDAT_ABBR_GENERIC_TZ "v" 00428 00435 #define UDAT_SPECIFIC_TZ "zzzz" 00436 00443 #define UDAT_ABBR_SPECIFIC_TZ "z" 00444 00451 #define UDAT_ABBR_UTC_TZ "ZZZZ" 00452 00453 /* deprecated skeleton constants */ 00454 00455 #ifndef U_HIDE_DEPRECATED_API 00456 00460 #define UDAT_STANDALONE_MONTH "LLLL" 00461 00465 #define UDAT_ABBR_STANDALONE_MONTH "LLL" 00466 00471 #define UDAT_HOUR_MINUTE_GENERIC_TZ "jmv" 00472 00476 #define UDAT_HOUR_MINUTE_TZ "jmz" 00477 00481 #define UDAT_HOUR_GENERIC_TZ "jv" 00482 00486 #define UDAT_HOUR_TZ "jz" 00487 #endif /* U_HIDE_DEPRECATED_API */ 00488 00489 #ifndef U_HIDE_INTERNAL_API 00490 00495 #define JP_ERA_2019_ROOT "Reiwa" 00496 00501 #define JP_ERA_2019_JA "\\u4EE4\\u548C" 00502 00507 #define JP_ERA_2019_NARROW "R" 00508 #endif // U_HIDE_INTERNAL_API 00509 00515 typedef enum UDateFormatField { 00521 UDAT_ERA_FIELD = 0, 00522 00528 UDAT_YEAR_FIELD = 1, 00529 00535 UDAT_MONTH_FIELD = 2, 00536 00542 UDAT_DATE_FIELD = 3, 00543 00551 UDAT_HOUR_OF_DAY1_FIELD = 4, 00552 00560 UDAT_HOUR_OF_DAY0_FIELD = 5, 00561 00567 UDAT_MINUTE_FIELD = 6, 00568 00574 UDAT_SECOND_FIELD = 7, 00575 00589 UDAT_FRACTIONAL_SECOND_FIELD = 8, 00590 00596 UDAT_DAY_OF_WEEK_FIELD = 9, 00597 00603 UDAT_DAY_OF_YEAR_FIELD = 10, 00604 00610 UDAT_DAY_OF_WEEK_IN_MONTH_FIELD = 11, 00611 00617 UDAT_WEEK_OF_YEAR_FIELD = 12, 00618 00624 UDAT_WEEK_OF_MONTH_FIELD = 13, 00625 00631 UDAT_AM_PM_FIELD = 14, 00632 00640 UDAT_HOUR1_FIELD = 15, 00641 00649 UDAT_HOUR0_FIELD = 16, 00650 00657 UDAT_TIMEZONE_FIELD = 17, 00658 00664 UDAT_YEAR_WOY_FIELD = 18, 00665 00671 UDAT_DOW_LOCAL_FIELD = 19, 00672 00678 UDAT_EXTENDED_YEAR_FIELD = 20, 00679 00685 UDAT_JULIAN_DAY_FIELD = 21, 00686 00692 UDAT_MILLISECONDS_IN_DAY_FIELD = 22, 00693 00700 UDAT_TIMEZONE_RFC_FIELD = 23, 00701 00707 UDAT_TIMEZONE_GENERIC_FIELD = 24, 00714 UDAT_STANDALONE_DAY_FIELD = 25, 00715 00722 UDAT_STANDALONE_MONTH_FIELD = 26, 00723 00731 UDAT_QUARTER_FIELD = 27, 00732 00740 UDAT_STANDALONE_QUARTER_FIELD = 28, 00741 00747 UDAT_TIMEZONE_SPECIAL_FIELD = 29, 00748 00756 UDAT_YEAR_NAME_FIELD = 30, 00757 00764 UDAT_TIMEZONE_LOCALIZED_GMT_OFFSET_FIELD = 31, 00765 00772 UDAT_TIMEZONE_ISO_FIELD = 32, 00773 00780 UDAT_TIMEZONE_ISO_LOCAL_FIELD = 33, 00781 00782 #ifndef U_HIDE_INTERNAL_API 00783 00788 UDAT_RELATED_YEAR_FIELD = 34, 00789 #endif /* U_HIDE_INTERNAL_API */ 00790 00797 UDAT_AM_PM_MIDNIGHT_NOON_FIELD = 35, 00798 00799 /* FieldPosition selector for 'B' field alignment. 00800 * Displays flexible day periods, such as "in the morning", if available. 00801 * @stable ICU 57 00802 */ 00803 UDAT_FLEXIBLE_DAY_PERIOD_FIELD = 36, 00804 00805 #ifndef U_HIDE_INTERNAL_API 00806 00812 UDAT_TIME_SEPARATOR_FIELD = 37, 00813 #endif /* U_HIDE_INTERNAL_API */ 00814 00815 #ifndef U_HIDE_DEPRECATED_API 00816 00822 UDAT_FIELD_COUNT = 38 00823 #endif /* U_HIDE_DEPRECATED_API */ 00824 } UDateFormatField; 00825 00826 00827 #ifndef U_HIDE_INTERNAL_API 00828 00833 #define UDAT_HAS_PATTERN_CHAR_FOR_TIME_SEPARATOR 0 00834 #endif /* U_HIDE_INTERNAL_API */ 00835 00836 00859 U_CAPI UCalendarDateFields U_EXPORT2 00860 udat_toCalendarDateField(UDateFormatField field); 00861 00862 00891 U_CAPI UDateFormat* U_EXPORT2 00892 udat_open(UDateFormatStyle timeStyle, 00893 UDateFormatStyle dateStyle, 00894 const char *locale, 00895 const UChar *tzID, 00896 int32_t tzIDLength, 00897 const UChar *pattern, 00898 int32_t patternLength, 00899 UErrorCode *status); 00900 00901 00908 U_CAPI void U_EXPORT2 00909 udat_close(UDateFormat* format); 00910 00911 00917 typedef enum UDateFormatBooleanAttribute { 00922 UDAT_PARSE_ALLOW_WHITESPACE = 0, 00928 UDAT_PARSE_ALLOW_NUMERIC = 1, 00934 UDAT_PARSE_PARTIAL_LITERAL_MATCH = 2, 00940 UDAT_PARSE_MULTIPLE_PATTERNS_FOR_MATCH = 3, 00941 00942 /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API, 00943 * it is needed for layout of DateFormat object. */ 00944 #ifndef U_FORCE_HIDE_DEPRECATED_API 00945 00949 UDAT_BOOLEAN_ATTRIBUTE_COUNT = 4 00950 #endif // U_FORCE_HIDE_DEPRECATED_API 00951 } UDateFormatBooleanAttribute; 00952 00963 U_CAPI UBool U_EXPORT2 00964 udat_getBooleanAttribute(const UDateFormat* fmt, UDateFormatBooleanAttribute attr, UErrorCode* status); 00965 00976 U_CAPI void U_EXPORT2 00977 udat_setBooleanAttribute(UDateFormat *fmt, UDateFormatBooleanAttribute attr, UBool newValue, UErrorCode* status); 00978 00983 typedef enum UDateFormatHourCycle { 00988 UDAT_HOUR_CYCLE_11, 00989 00994 UDAT_HOUR_CYCLE_12, 00995 01000 UDAT_HOUR_CYCLE_23, 01001 01006 UDAT_HOUR_CYCLE_24 01007 } UDateFormatHourCycle; 01008 01009 #if U_SHOW_CPLUSPLUS_API 01010 01011 U_NAMESPACE_BEGIN 01012 01022 U_DEFINE_LOCAL_OPEN_POINTER(LocalUDateFormatPointer, UDateFormat, udat_close); 01023 01024 U_NAMESPACE_END 01025 01026 #endif 01027 01036 U_CAPI UDateFormat* U_EXPORT2 01037 udat_clone(const UDateFormat *fmt, 01038 UErrorCode *status); 01039 01058 U_CAPI int32_t U_EXPORT2 01059 udat_format( const UDateFormat* format, 01060 UDate dateToFormat, 01061 UChar* result, 01062 int32_t resultLength, 01063 UFieldPosition* position, 01064 UErrorCode* status); 01065 01088 U_CAPI int32_t U_EXPORT2 01089 udat_formatCalendar( const UDateFormat* format, 01090 UCalendar* calendar, 01091 UChar* result, 01092 int32_t capacity, 01093 UFieldPosition* position, 01094 UErrorCode* status); 01095 01123 U_CAPI int32_t U_EXPORT2 01124 udat_formatForFields( const UDateFormat* format, 01125 UDate dateToFormat, 01126 UChar* result, 01127 int32_t resultLength, 01128 UFieldPositionIterator* fpositer, 01129 UErrorCode* status); 01130 01161 U_CAPI int32_t U_EXPORT2 01162 udat_formatCalendarForFields( const UDateFormat* format, 01163 UCalendar* calendar, 01164 UChar* result, 01165 int32_t capacity, 01166 UFieldPositionIterator* fpositer, 01167 UErrorCode* status); 01168 01169 01195 U_CAPI UDate U_EXPORT2 01196 udat_parse(const UDateFormat* format, 01197 const UChar* text, 01198 int32_t textLength, 01199 int32_t *parsePos, 01200 UErrorCode *status); 01201 01223 U_CAPI void U_EXPORT2 01224 udat_parseCalendar(const UDateFormat* format, 01225 UCalendar* calendar, 01226 const UChar* text, 01227 int32_t textLength, 01228 int32_t *parsePos, 01229 UErrorCode *status); 01230 01240 U_CAPI UBool U_EXPORT2 01241 udat_isLenient(const UDateFormat* fmt); 01242 01252 U_CAPI void U_EXPORT2 01253 udat_setLenient( UDateFormat* fmt, 01254 UBool isLenient); 01255 01265 U_CAPI const UCalendar* U_EXPORT2 01266 udat_getCalendar(const UDateFormat* fmt); 01267 01277 U_CAPI void U_EXPORT2 01278 udat_setCalendar( UDateFormat* fmt, 01279 const UCalendar* calendarToSet); 01280 01290 U_CAPI const UNumberFormat* U_EXPORT2 01291 udat_getNumberFormat(const UDateFormat* fmt); 01292 01302 U_CAPI const UNumberFormat* U_EXPORT2 01303 udat_getNumberFormatForField(const UDateFormat* fmt, UChar field); 01304 01320 U_CAPI void U_EXPORT2 01321 udat_adoptNumberFormatForFields( UDateFormat* fmt, 01322 const UChar* fields, 01323 UNumberFormat* numberFormatToSet, 01324 UErrorCode* status); 01337 U_CAPI void U_EXPORT2 01338 udat_setNumberFormat( UDateFormat* fmt, 01339 const UNumberFormat* numberFormatToSet); 01349 U_CAPI void U_EXPORT2 01350 udat_adoptNumberFormat( UDateFormat* fmt, 01351 UNumberFormat* numberFormatToAdopt); 01361 U_CAPI const char* U_EXPORT2 01362 udat_getAvailable(int32_t localeIndex); 01363 01372 U_CAPI int32_t U_EXPORT2 01373 udat_countAvailable(void); 01374 01385 U_CAPI UDate U_EXPORT2 01386 udat_get2DigitYearStart( const UDateFormat *fmt, 01387 UErrorCode *status); 01388 01399 U_CAPI void U_EXPORT2 01400 udat_set2DigitYearStart( UDateFormat *fmt, 01401 UDate d, 01402 UErrorCode *status); 01403 01416 U_CAPI int32_t U_EXPORT2 01417 udat_toPattern( const UDateFormat *fmt, 01418 UBool localized, 01419 UChar *result, 01420 int32_t resultLength, 01421 UErrorCode *status); 01422 01433 U_CAPI void U_EXPORT2 01434 udat_applyPattern( UDateFormat *format, 01435 UBool localized, 01436 const UChar *pattern, 01437 int32_t patternLength); 01438 01443 typedef enum UDateFormatSymbolType { 01445 UDAT_ERAS, 01447 UDAT_MONTHS, 01449 UDAT_SHORT_MONTHS, 01451 UDAT_WEEKDAYS, 01456 UDAT_SHORT_WEEKDAYS, 01458 UDAT_AM_PMS, 01460 UDAT_LOCALIZED_CHARS, 01462 UDAT_ERA_NAMES, 01464 UDAT_NARROW_MONTHS, 01466 UDAT_NARROW_WEEKDAYS, 01468 UDAT_STANDALONE_MONTHS, 01469 UDAT_STANDALONE_SHORT_MONTHS, 01470 UDAT_STANDALONE_NARROW_MONTHS, 01472 UDAT_STANDALONE_WEEKDAYS, 01477 UDAT_STANDALONE_SHORT_WEEKDAYS, 01479 UDAT_STANDALONE_NARROW_WEEKDAYS, 01481 UDAT_QUARTERS, 01483 UDAT_SHORT_QUARTERS, 01485 UDAT_STANDALONE_QUARTERS, 01486 UDAT_STANDALONE_SHORT_QUARTERS, 01494 UDAT_SHORTER_WEEKDAYS, 01499 UDAT_STANDALONE_SHORTER_WEEKDAYS, 01505 UDAT_CYCLIC_YEARS_WIDE, 01510 UDAT_CYCLIC_YEARS_ABBREVIATED, 01516 UDAT_CYCLIC_YEARS_NARROW, 01522 UDAT_ZODIAC_NAMES_WIDE, 01527 UDAT_ZODIAC_NAMES_ABBREVIATED, 01533 UDAT_ZODIAC_NAMES_NARROW, 01534 01539 UDAT_NARROW_QUARTERS, 01540 01545 UDAT_STANDALONE_NARROW_QUARTERS 01546 } UDateFormatSymbolType; 01547 01548 struct UDateFormatSymbols; 01553 typedef struct UDateFormatSymbols UDateFormatSymbols; 01554 01571 U_CAPI int32_t U_EXPORT2 01572 udat_getSymbols(const UDateFormat *fmt, 01573 UDateFormatSymbolType type, 01574 int32_t symbolIndex, 01575 UChar *result, 01576 int32_t resultLength, 01577 UErrorCode *status); 01578 01591 U_CAPI int32_t U_EXPORT2 01592 udat_countSymbols( const UDateFormat *fmt, 01593 UDateFormatSymbolType type); 01594 01610 U_CAPI void U_EXPORT2 01611 udat_setSymbols( UDateFormat *format, 01612 UDateFormatSymbolType type, 01613 int32_t symbolIndex, 01614 UChar *value, 01615 int32_t valueLength, 01616 UErrorCode *status); 01617 01627 U_CAPI const char* U_EXPORT2 01628 udat_getLocaleByType(const UDateFormat *fmt, 01629 ULocDataLocaleType type, 01630 UErrorCode* status); 01631 01640 U_CAPI void U_EXPORT2 01641 udat_setContext(UDateFormat* fmt, UDisplayContext value, UErrorCode* status); 01642 01652 U_CAPI UDisplayContext U_EXPORT2 01653 udat_getContext(const UDateFormat* fmt, UDisplayContextType type, UErrorCode* status); 01654 01655 #ifndef U_HIDE_INTERNAL_API 01656 01667 U_CAPI int32_t U_EXPORT2 01668 udat_toPatternRelativeDate(const UDateFormat *fmt, 01669 UChar *result, 01670 int32_t resultLength, 01671 UErrorCode *status); 01672 01684 U_CAPI int32_t U_EXPORT2 01685 udat_toPatternRelativeTime(const UDateFormat *fmt, 01686 UChar *result, 01687 int32_t resultLength, 01688 UErrorCode *status); 01689 01702 U_CAPI void U_EXPORT2 01703 udat_applyPatternRelative(UDateFormat *format, 01704 const UChar *datePattern, 01705 int32_t datePatternLength, 01706 const UChar *timePattern, 01707 int32_t timePatternLength, 01708 UErrorCode *status); 01709 01714 typedef UDateFormat* (U_EXPORT2 *UDateFormatOpener) (UDateFormatStyle timeStyle, 01715 UDateFormatStyle dateStyle, 01716 const char *locale, 01717 const UChar *tzID, 01718 int32_t tzIDLength, 01719 const UChar *pattern, 01720 int32_t patternLength, 01721 UErrorCode *status); 01722 01727 U_CAPI void U_EXPORT2 01728 udat_registerOpener(UDateFormatOpener opener, UErrorCode *status); 01729 01734 U_CAPI UDateFormatOpener U_EXPORT2 01735 udat_unregisterOpener(UDateFormatOpener opener, UErrorCode *status); 01736 #endif /* U_HIDE_INTERNAL_API */ 01737 01738 01739 #endif /* #if !UCONFIG_NO_FORMATTING */ 01740 01741 #endif
1.7.6.1