ICU 54.1 54.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
udat.h
Go to the documentation of this file.
1 /*
2 *******************************************************************************
3 * Copyright (C) 1996-2014, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 *******************************************************************************
6 */
7
8 #ifndef UDAT_H
9 #define UDAT_H
10
11 #include "unicode/utypes.h"
12
13 #if !UCONFIG_NO_FORMATTING
14
15 #include "unicode/localpointer.h"
16 #include "unicode/ucal.h"
17 #include "unicode/unum.h"
18 #include "unicode/udisplaycontext.h"
150 typedef void* UDateFormat;
151
155 typedef enum UDateFormatStyle {
157 UDAT_FULL,
159 UDAT_LONG,
161 UDAT_MEDIUM,
163 UDAT_SHORT,
165 UDAT_DEFAULT = UDAT_MEDIUM,
166
168 UDAT_RELATIVE = (1 << 7),
169
170 UDAT_FULL_RELATIVE = UDAT_FULL | UDAT_RELATIVE,
171
172 UDAT_LONG_RELATIVE = UDAT_LONG | UDAT_RELATIVE,
173
174 UDAT_MEDIUM_RELATIVE = UDAT_MEDIUM | UDAT_RELATIVE,
175
176 UDAT_SHORT_RELATIVE = UDAT_SHORT | UDAT_RELATIVE,
177
178
180 UDAT_NONE = -1,
181
187 UDAT_PATTERN = -2,
188
189 #ifndef U_HIDE_INTERNAL_API
191 UDAT_IGNORE = UDAT_PATTERN
192 #endif /* U_HIDE_INTERNAL_API */
193 } UDateFormatStyle;
194
195 /* Skeletons for dates. */
196
201 #define UDAT_YEAR "y"
202
206 #define UDAT_QUARTER "QQQQ"
207
211 #define UDAT_ABBR_QUARTER "QQQ"
212
216 #define UDAT_YEAR_QUARTER "yQQQQ"
217
221 #define UDAT_YEAR_ABBR_QUARTER "yQQQ"
222
226 #define UDAT_MONTH "MMMM"
227
231 #define UDAT_ABBR_MONTH "MMM"
232
236 #define UDAT_NUM_MONTH "M"
237
241 #define UDAT_YEAR_MONTH "yMMMM"
242
246 #define UDAT_YEAR_ABBR_MONTH "yMMM"
247
251 #define UDAT_YEAR_NUM_MONTH "yM"
252
256 #define UDAT_DAY "d"
257
262 #define UDAT_YEAR_MONTH_DAY "yMMMMd"
263
268 #define UDAT_YEAR_ABBR_MONTH_DAY "yMMMd"
269
274 #define UDAT_YEAR_NUM_MONTH_DAY "yMd"
275
279 #define UDAT_WEEKDAY "EEEE"
280
284 #define UDAT_ABBR_WEEKDAY "E"
285
290 #define UDAT_YEAR_MONTH_WEEKDAY_DAY "yMMMMEEEEd"
291
296 #define UDAT_YEAR_ABBR_MONTH_WEEKDAY_DAY "yMMMEd"
297
302 #define UDAT_YEAR_NUM_MONTH_WEEKDAY_DAY "yMEd"
303
308 #define UDAT_MONTH_DAY "MMMMd"
309
314 #define UDAT_ABBR_MONTH_DAY "MMMd"
315
320 #define UDAT_NUM_MONTH_DAY "Md"
321
326 #define UDAT_MONTH_WEEKDAY_DAY "MMMMEEEEd"
327
332 #define UDAT_ABBR_MONTH_WEEKDAY_DAY "MMMEd"
333
338 #define UDAT_NUM_MONTH_WEEKDAY_DAY "MEd"
339
340 /* Skeletons for times. */
341
346 #define UDAT_HOUR "j"
347
351 #define UDAT_HOUR24 "H"
352
356 #define UDAT_MINUTE "m"
357
362 #define UDAT_HOUR_MINUTE "jm"
363
368 #define UDAT_HOUR24_MINUTE "Hm"
369
373 #define UDAT_SECOND "s"
374
380 #define UDAT_HOUR_MINUTE_SECOND "jms"
381
387 #define UDAT_HOUR24_MINUTE_SECOND "Hms"
388
393 #define UDAT_MINUTE_SECOND "ms"
394
395 /* Skeletons for time zones. */
396
404 #define UDAT_LOCATION_TZ "VVVV"
405
412 #define UDAT_GENERIC_TZ "vvvv"
413
420 #define UDAT_ABBR_GENERIC_TZ "v"
421
428 #define UDAT_SPECIFIC_TZ "zzzz"
429
436 #define UDAT_ABBR_SPECIFIC_TZ "z"
437
444 #define UDAT_ABBR_UTC_TZ "ZZZZ"
445
446 /* deprecated skeleton constants */
447
448 #ifndef U_HIDE_DEPRECATED_API
449
453 #define UDAT_STANDALONE_MONTH "LLLL"
454
458 #define UDAT_ABBR_STANDALONE_MONTH "LLL"
459
464 #define UDAT_HOUR_MINUTE_GENERIC_TZ "jmv"
465
469 #define UDAT_HOUR_MINUTE_TZ "jmz"
470
474 #define UDAT_HOUR_GENERIC_TZ "jv"
475
479 #define UDAT_HOUR_TZ "jz"
480 #endif /* U_HIDE_DEPRECATED_API */
481
487 typedef enum UDateFormatField {
493 UDAT_ERA_FIELD = 0,
494
500 UDAT_YEAR_FIELD = 1,
501
507 UDAT_MONTH_FIELD = 2,
508
514 UDAT_DATE_FIELD = 3,
515
523 UDAT_HOUR_OF_DAY1_FIELD = 4,
524
532 UDAT_HOUR_OF_DAY0_FIELD = 5,
533
539 UDAT_MINUTE_FIELD = 6,
540
546 UDAT_SECOND_FIELD = 7,
547
561 UDAT_FRACTIONAL_SECOND_FIELD = 8,
562
568 UDAT_DAY_OF_WEEK_FIELD = 9,
569
575 UDAT_DAY_OF_YEAR_FIELD = 10,
576
582 UDAT_DAY_OF_WEEK_IN_MONTH_FIELD = 11,
583
589 UDAT_WEEK_OF_YEAR_FIELD = 12,
590
596 UDAT_WEEK_OF_MONTH_FIELD = 13,
597
603 UDAT_AM_PM_FIELD = 14,
604
612 UDAT_HOUR1_FIELD = 15,
613
621 UDAT_HOUR0_FIELD = 16,
622
629 UDAT_TIMEZONE_FIELD = 17,
630
636 UDAT_YEAR_WOY_FIELD = 18,
637
643 UDAT_DOW_LOCAL_FIELD = 19,
644
650 UDAT_EXTENDED_YEAR_FIELD = 20,
651
657 UDAT_JULIAN_DAY_FIELD = 21,
658
664 UDAT_MILLISECONDS_IN_DAY_FIELD = 22,
665
672 UDAT_TIMEZONE_RFC_FIELD = 23,
673
679 UDAT_TIMEZONE_GENERIC_FIELD = 24,
686 UDAT_STANDALONE_DAY_FIELD = 25,
687
694 UDAT_STANDALONE_MONTH_FIELD = 26,
695
703 UDAT_QUARTER_FIELD = 27,
704
712 UDAT_STANDALONE_QUARTER_FIELD = 28,
713
719 UDAT_TIMEZONE_SPECIAL_FIELD = 29,
720
728 UDAT_YEAR_NAME_FIELD = 30,
729
736 UDAT_TIMEZONE_LOCALIZED_GMT_OFFSET_FIELD = 31,
737
744 UDAT_TIMEZONE_ISO_FIELD = 32,
745
752 UDAT_TIMEZONE_ISO_LOCAL_FIELD = 33,
753
754 #ifndef U_HIDE_INTERNAL_API
755
760 UDAT_RELATED_YEAR_FIELD = 34,
761 #endif /* U_HIDE_INTERNAL_API */
762
771 UDAT_FIELD_COUNT = 35
772
773 } UDateFormatField;
774
775
784 U_STABLE UCalendarDateFields U_EXPORT2
785 udat_toCalendarDateField(UDateFormatField field);
786
787
816 U_STABLE UDateFormat* U_EXPORT2
817 udat_open(UDateFormatStyle timeStyle,
818 UDateFormatStyle dateStyle,
819 const char *locale,
820 const UChar *tzID,
821 int32_t tzIDLength,
822 const UChar *pattern,
823 int32_t patternLength,
824 UErrorCode *status);
825
826
833 U_STABLE void U_EXPORT2
834 udat_close(UDateFormat* format);
835
836
837 /* Dont hide UDateFormatBooleanAttribute type with #ifndef U_HIDE_DRAFT_API, needed by virtual methods */
838 /* Also don't hide UDAT_BOOLEAN_ATTRIBUTE_COUNT, needed by template class EnumSet<UDateFormatBooleanAttribute,...> */
844 typedef enum UDateFormatBooleanAttribute {
845 #ifndef U_HIDE_DRAFT_API
846
850 UDAT_PARSE_ALLOW_WHITESPACE = 0,
856 UDAT_PARSE_ALLOW_NUMERIC = 1,
861 UDAT_PARSE_PARTIAL_MATCH = 2,
867 UDAT_PARSE_MULTIPLE_PATTERNS_FOR_MATCH = 3,
868 #endif /* U_HIDE_DRAFT_API */
869
873 UDAT_BOOLEAN_ATTRIBUTE_COUNT = 4
874 } UDateFormatBooleanAttribute;
875
876 #ifndef U_HIDE_DRAFT_API
877
887 U_DRAFT UBool U_EXPORT2
888 udat_getBooleanAttribute(const UDateFormat* fmt, UDateFormatBooleanAttribute attr, UErrorCode* status);
889
900 U_DRAFT void U_EXPORT2
901 udat_setBooleanAttribute(UDateFormat *fmt, UDateFormatBooleanAttribute attr, UBool newValue, UErrorCode* status);
902
903 #endif /* U_HIDE_DRAFT_API */
904
905
906
907 #if U_SHOW_CPLUSPLUS_API
908
909 U_NAMESPACE_BEGIN
910
920 U_DEFINE_LOCAL_OPEN_POINTER(LocalUDateFormatPointer, UDateFormat, udat_close);
921
922 U_NAMESPACE_END
923
924 #endif
925
934 U_STABLE UDateFormat* U_EXPORT2
935 udat_clone(const UDateFormat *fmt,
936 UErrorCode *status);
937
956 U_STABLE int32_t U_EXPORT2
957 udat_format( const UDateFormat* format,
958 UDate dateToFormat,
959 UChar* result,
960 int32_t resultLength,
961 UFieldPosition* position,
962 UErrorCode* status);
963
989 U_STABLE UDate U_EXPORT2
990 udat_parse(const UDateFormat* format,
991 const UChar* text,
992 int32_t textLength,
993 int32_t *parsePos,
994 UErrorCode *status);
995
1017 U_STABLE void U_EXPORT2
1018 udat_parseCalendar(const UDateFormat* format,
1019 UCalendar* calendar,
1020 const UChar* text,
1021 int32_t textLength,
1022 int32_t *parsePos,
1023 UErrorCode *status);
1024
1034 U_STABLE UBool U_EXPORT2
1035 udat_isLenient(const UDateFormat* fmt);
1036
1046 U_STABLE void U_EXPORT2
1047 udat_setLenient( UDateFormat* fmt,
1048 UBool isLenient);
1049
1059 U_STABLE const UCalendar* U_EXPORT2
1060 udat_getCalendar(const UDateFormat* fmt);
1061
1071 U_STABLE void U_EXPORT2
1072 udat_setCalendar( UDateFormat* fmt,
1073 const UCalendar* calendarToSet);
1074
1084 U_STABLE const UNumberFormat* U_EXPORT2
1085 udat_getNumberFormat(const UDateFormat* fmt);
1086
1087 #ifndef U_HIDE_DRAFT_API
1088
1097 U_DRAFT const UNumberFormat* U_EXPORT2
1098 udat_getNumberFormatForField(const UDateFormat* fmt, UChar field);
1099
1115 U_DRAFT void U_EXPORT2
1116 udat_adoptNumberFormatForFields( UDateFormat* fmt,
1117 const UChar* fields,
1118 UNumberFormat* numberFormatToSet,
1119 UErrorCode* status);
1120 #endif /* U_HIDE_DRAFT_API */
1121
1134 U_STABLE void U_EXPORT2
1135 udat_setNumberFormat( UDateFormat* fmt,
1136 const UNumberFormat* numberFormatToSet);
1137
1138 #ifndef U_HIDE_DRAFT_API
1139
1148 U_DRAFT void U_EXPORT2
1149 udat_adoptNumberFormat( UDateFormat* fmt,
1150 UNumberFormat* numberFormatToAdopt);
1151 #endif /* U_HIDE_DRAFT_API */
1152
1162 U_STABLE const char* U_EXPORT2
1163 udat_getAvailable(int32_t localeIndex);
1164
1173 U_STABLE int32_t U_EXPORT2
1174 udat_countAvailable(void);
1175
1186 U_STABLE UDate U_EXPORT2
1187 udat_get2DigitYearStart( const UDateFormat *fmt,
1188 UErrorCode *status);
1189
1200 U_STABLE void U_EXPORT2
1201 udat_set2DigitYearStart( UDateFormat *fmt,
1202 UDate d,
1203 UErrorCode *status);
1204
1217 U_STABLE int32_t U_EXPORT2
1218 udat_toPattern( const UDateFormat *fmt,
1219 UBool localized,
1220 UChar *result,
1221 int32_t resultLength,
1222 UErrorCode *status);
1223
1234 U_STABLE void U_EXPORT2
1235 udat_applyPattern( UDateFormat *format,
1236 UBool localized,
1237 const UChar *pattern,
1238 int32_t patternLength);
1239
1244 typedef enum UDateFormatSymbolType {
1246 UDAT_ERAS,
1248 UDAT_MONTHS,
1250 UDAT_SHORT_MONTHS,
1252 UDAT_WEEKDAYS,
1257 UDAT_SHORT_WEEKDAYS,
1259 UDAT_AM_PMS,
1261 UDAT_LOCALIZED_CHARS,
1263 UDAT_ERA_NAMES,
1265 UDAT_NARROW_MONTHS,
1267 UDAT_NARROW_WEEKDAYS,
1269 UDAT_STANDALONE_MONTHS,
1270 UDAT_STANDALONE_SHORT_MONTHS,
1271 UDAT_STANDALONE_NARROW_MONTHS,
1273 UDAT_STANDALONE_WEEKDAYS,
1278 UDAT_STANDALONE_SHORT_WEEKDAYS,
1280 UDAT_STANDALONE_NARROW_WEEKDAYS,
1282 UDAT_QUARTERS,
1284 UDAT_SHORT_QUARTERS,
1286 UDAT_STANDALONE_QUARTERS,
1287 UDAT_STANDALONE_SHORT_QUARTERS,
1295 UDAT_SHORTER_WEEKDAYS,
1300 UDAT_STANDALONE_SHORTER_WEEKDAYS
1301 #ifndef U_HIDE_DRAFT_API
1302 ,
1308 UDAT_CYCLIC_YEARS_WIDE,
1313 UDAT_CYCLIC_YEARS_ABBREVIATED,
1319 UDAT_CYCLIC_YEARS_NARROW,
1325 UDAT_ZODIAC_NAMES_WIDE,
1330 UDAT_ZODIAC_NAMES_ABBREVIATED,
1336 UDAT_ZODIAC_NAMES_NARROW
1337 #endif /* U_HIDE_DRAFT_API */
1338 } UDateFormatSymbolType;
1339
1340 struct UDateFormatSymbols;
1345 typedef struct UDateFormatSymbols UDateFormatSymbols;
1346
1363 U_STABLE int32_t U_EXPORT2
1364 udat_getSymbols(const UDateFormat *fmt,
1365 UDateFormatSymbolType type,
1366 int32_t symbolIndex,
1367 UChar *result,
1368 int32_t resultLength,
1369 UErrorCode *status);
1370
1383 U_STABLE int32_t U_EXPORT2
1384 udat_countSymbols( const UDateFormat *fmt,
1385 UDateFormatSymbolType type);
1386
1402 U_STABLE void U_EXPORT2
1403 udat_setSymbols( UDateFormat *format,
1404 UDateFormatSymbolType type,
1405 int32_t symbolIndex,
1406 UChar *value,
1407 int32_t valueLength,
1408 UErrorCode *status);
1409
1419 U_STABLE const char* U_EXPORT2
1420 udat_getLocaleByType(const UDateFormat *fmt,
1421 ULocDataLocaleType type,
1422 UErrorCode* status);
1423
1432 U_DRAFT void U_EXPORT2
1433 udat_setContext(UDateFormat* fmt, UDisplayContext value, UErrorCode* status);
1434
1435 #ifndef U_HIDE_DRAFT_API
1436
1445 U_DRAFT UDisplayContext U_EXPORT2
1446 udat_getContext(const UDateFormat* fmt, UDisplayContextType type, UErrorCode* status);
1447
1448 #endif /* U_HIDE_DRAFT_API */
1449
1450 #ifndef U_HIDE_INTERNAL_API
1451
1462 U_INTERNAL int32_t U_EXPORT2
1463 udat_toPatternRelativeDate(const UDateFormat *fmt,
1464 UChar *result,
1465 int32_t resultLength,
1466 UErrorCode *status);
1467
1479 U_INTERNAL int32_t U_EXPORT2
1480 udat_toPatternRelativeTime(const UDateFormat *fmt,
1481 UChar *result,
1482 int32_t resultLength,
1483 UErrorCode *status);
1484
1497 U_INTERNAL void U_EXPORT2
1498 udat_applyPatternRelative(UDateFormat *format,
1499 const UChar *datePattern,
1500 int32_t datePatternLength,
1501 const UChar *timePattern,
1502 int32_t timePatternLength,
1503 UErrorCode *status);
1504
1509 typedef UDateFormat* (U_EXPORT2 *UDateFormatOpener) (UDateFormatStyle timeStyle,
1510 UDateFormatStyle dateStyle,
1511 const char *locale,
1512 const UChar *tzID,
1513 int32_t tzIDLength,
1514 const UChar *pattern,
1515 int32_t patternLength,
1516 UErrorCode *status);
1517
1522 U_INTERNAL void U_EXPORT2
1523 udat_registerOpener(UDateFormatOpener opener, UErrorCode *status);
1524
1529 U_INTERNAL UDateFormatOpener U_EXPORT2
1530 udat_unregisterOpener(UDateFormatOpener opener, UErrorCode *status);
1531 #endif /* U_HIDE_INTERNAL_API */
1532
1533
1534 #endif /* #if !UCONFIG_NO_FORMATTING */
1535
1536 #endif