ICU 55.1 55.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-2015, 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"
19 #include "unicode/ufieldpositer.h"
151 typedef void* UDateFormat;
152
156 typedef enum UDateFormatStyle {
158 UDAT_FULL,
160 UDAT_LONG,
162 UDAT_MEDIUM,
164 UDAT_SHORT,
166 UDAT_DEFAULT = UDAT_MEDIUM,
167
169 UDAT_RELATIVE = (1 << 7),
170
171 UDAT_FULL_RELATIVE = UDAT_FULL | UDAT_RELATIVE,
172
173 UDAT_LONG_RELATIVE = UDAT_LONG | UDAT_RELATIVE,
174
175 UDAT_MEDIUM_RELATIVE = UDAT_MEDIUM | UDAT_RELATIVE,
176
177 UDAT_SHORT_RELATIVE = UDAT_SHORT | UDAT_RELATIVE,
178
179
181 UDAT_NONE = -1,
182
188 UDAT_PATTERN = -2,
189
190 #ifndef U_HIDE_INTERNAL_API
192 UDAT_IGNORE = UDAT_PATTERN
193 #endif /* U_HIDE_INTERNAL_API */
194 } UDateFormatStyle;
195
196 /* Skeletons for dates. */
197
202 #define UDAT_YEAR "y"
203
207 #define UDAT_QUARTER "QQQQ"
208
212 #define UDAT_ABBR_QUARTER "QQQ"
213
217 #define UDAT_YEAR_QUARTER "yQQQQ"
218
222 #define UDAT_YEAR_ABBR_QUARTER "yQQQ"
223
227 #define UDAT_MONTH "MMMM"
228
232 #define UDAT_ABBR_MONTH "MMM"
233
237 #define UDAT_NUM_MONTH "M"
238
242 #define UDAT_YEAR_MONTH "yMMMM"
243
247 #define UDAT_YEAR_ABBR_MONTH "yMMM"
248
252 #define UDAT_YEAR_NUM_MONTH "yM"
253
257 #define UDAT_DAY "d"
258
263 #define UDAT_YEAR_MONTH_DAY "yMMMMd"
264
269 #define UDAT_YEAR_ABBR_MONTH_DAY "yMMMd"
270
275 #define UDAT_YEAR_NUM_MONTH_DAY "yMd"
276
280 #define UDAT_WEEKDAY "EEEE"
281
285 #define UDAT_ABBR_WEEKDAY "E"
286
291 #define UDAT_YEAR_MONTH_WEEKDAY_DAY "yMMMMEEEEd"
292
297 #define UDAT_YEAR_ABBR_MONTH_WEEKDAY_DAY "yMMMEd"
298
303 #define UDAT_YEAR_NUM_MONTH_WEEKDAY_DAY "yMEd"
304
309 #define UDAT_MONTH_DAY "MMMMd"
310
315 #define UDAT_ABBR_MONTH_DAY "MMMd"
316
321 #define UDAT_NUM_MONTH_DAY "Md"
322
327 #define UDAT_MONTH_WEEKDAY_DAY "MMMMEEEEd"
328
333 #define UDAT_ABBR_MONTH_WEEKDAY_DAY "MMMEd"
334
339 #define UDAT_NUM_MONTH_WEEKDAY_DAY "MEd"
340
341 /* Skeletons for times. */
342
347 #define UDAT_HOUR "j"
348
352 #define UDAT_HOUR24 "H"
353
357 #define UDAT_MINUTE "m"
358
363 #define UDAT_HOUR_MINUTE "jm"
364
369 #define UDAT_HOUR24_MINUTE "Hm"
370
374 #define UDAT_SECOND "s"
375
381 #define UDAT_HOUR_MINUTE_SECOND "jms"
382
388 #define UDAT_HOUR24_MINUTE_SECOND "Hms"
389
394 #define UDAT_MINUTE_SECOND "ms"
395
396 /* Skeletons for time zones. */
397
405 #define UDAT_LOCATION_TZ "VVVV"
406
413 #define UDAT_GENERIC_TZ "vvvv"
414
421 #define UDAT_ABBR_GENERIC_TZ "v"
422
429 #define UDAT_SPECIFIC_TZ "zzzz"
430
437 #define UDAT_ABBR_SPECIFIC_TZ "z"
438
445 #define UDAT_ABBR_UTC_TZ "ZZZZ"
446
447 /* deprecated skeleton constants */
448
449 #ifndef U_HIDE_DEPRECATED_API
450
454 #define UDAT_STANDALONE_MONTH "LLLL"
455
459 #define UDAT_ABBR_STANDALONE_MONTH "LLL"
460
465 #define UDAT_HOUR_MINUTE_GENERIC_TZ "jmv"
466
470 #define UDAT_HOUR_MINUTE_TZ "jmz"
471
475 #define UDAT_HOUR_GENERIC_TZ "jv"
476
480 #define UDAT_HOUR_TZ "jz"
481 #endif /* U_HIDE_DEPRECATED_API */
482
488 typedef enum UDateFormatField {
494 UDAT_ERA_FIELD = 0,
495
501 UDAT_YEAR_FIELD = 1,
502
508 UDAT_MONTH_FIELD = 2,
509
515 UDAT_DATE_FIELD = 3,
516
524 UDAT_HOUR_OF_DAY1_FIELD = 4,
525
533 UDAT_HOUR_OF_DAY0_FIELD = 5,
534
540 UDAT_MINUTE_FIELD = 6,
541
547 UDAT_SECOND_FIELD = 7,
548
562 UDAT_FRACTIONAL_SECOND_FIELD = 8,
563
569 UDAT_DAY_OF_WEEK_FIELD = 9,
570
576 UDAT_DAY_OF_YEAR_FIELD = 10,
577
583 UDAT_DAY_OF_WEEK_IN_MONTH_FIELD = 11,
584
590 UDAT_WEEK_OF_YEAR_FIELD = 12,
591
597 UDAT_WEEK_OF_MONTH_FIELD = 13,
598
604 UDAT_AM_PM_FIELD = 14,
605
613 UDAT_HOUR1_FIELD = 15,
614
622 UDAT_HOUR0_FIELD = 16,
623
630 UDAT_TIMEZONE_FIELD = 17,
631
637 UDAT_YEAR_WOY_FIELD = 18,
638
644 UDAT_DOW_LOCAL_FIELD = 19,
645
651 UDAT_EXTENDED_YEAR_FIELD = 20,
652
658 UDAT_JULIAN_DAY_FIELD = 21,
659
665 UDAT_MILLISECONDS_IN_DAY_FIELD = 22,
666
673 UDAT_TIMEZONE_RFC_FIELD = 23,
674
680 UDAT_TIMEZONE_GENERIC_FIELD = 24,
687 UDAT_STANDALONE_DAY_FIELD = 25,
688
695 UDAT_STANDALONE_MONTH_FIELD = 26,
696
704 UDAT_QUARTER_FIELD = 27,
705
713 UDAT_STANDALONE_QUARTER_FIELD = 28,
714
720 UDAT_TIMEZONE_SPECIAL_FIELD = 29,
721
729 UDAT_YEAR_NAME_FIELD = 30,
730
737 UDAT_TIMEZONE_LOCALIZED_GMT_OFFSET_FIELD = 31,
738
745 UDAT_TIMEZONE_ISO_FIELD = 32,
746
753 UDAT_TIMEZONE_ISO_LOCAL_FIELD = 33,
754
755 #ifndef U_HIDE_INTERNAL_API
756
761 UDAT_RELATED_YEAR_FIELD = 34,
762 #endif /* U_HIDE_INTERNAL_API */
763
764 #ifndef U_HIDE_DRAFT_API
765
770 UDAT_TIME_SEPARATOR_FIELD = 35,
771 #endif /* U_HIDE_DRAFT_API */
772
781 UDAT_FIELD_COUNT = 36
782
783 } UDateFormatField;
784
785
794 U_STABLE UCalendarDateFields U_EXPORT2
795 udat_toCalendarDateField(UDateFormatField field);
796
797
826 U_STABLE UDateFormat* U_EXPORT2
827 udat_open(UDateFormatStyle timeStyle,
828 UDateFormatStyle dateStyle,
829 const char *locale,
830 const UChar *tzID,
831 int32_t tzIDLength,
832 const UChar *pattern,
833 int32_t patternLength,
834 UErrorCode *status);
835
836
843 U_STABLE void U_EXPORT2
844 udat_close(UDateFormat* format);
845
846
852 typedef enum UDateFormatBooleanAttribute {
857 UDAT_PARSE_ALLOW_WHITESPACE = 0,
863 UDAT_PARSE_ALLOW_NUMERIC = 1,
864 #ifndef U_HIDE_DRAFT_API
865
869 UDAT_PARSE_PARTIAL_MATCH = 2,
875 UDAT_PARSE_MULTIPLE_PATTERNS_FOR_MATCH = 3,
876 #endif /* U_HIDE_DRAFT_API */
877
881 UDAT_BOOLEAN_ATTRIBUTE_COUNT = 4
882 } UDateFormatBooleanAttribute;
883
894 U_STABLE UBool U_EXPORT2
895 udat_getBooleanAttribute(const UDateFormat* fmt, UDateFormatBooleanAttribute attr, UErrorCode* status);
896
907 U_STABLE void U_EXPORT2
908 udat_setBooleanAttribute(UDateFormat *fmt, UDateFormatBooleanAttribute attr, UBool newValue, UErrorCode* status);
909
910
911
912 #if U_SHOW_CPLUSPLUS_API
913
914 U_NAMESPACE_BEGIN
915
925 U_DEFINE_LOCAL_OPEN_POINTER(LocalUDateFormatPointer, UDateFormat, udat_close);
926
927 U_NAMESPACE_END
928
929 #endif
930
939 U_STABLE UDateFormat* U_EXPORT2
940 udat_clone(const UDateFormat *fmt,
941 UErrorCode *status);
942
961 U_STABLE int32_t U_EXPORT2
962 udat_format( const UDateFormat* format,
963 UDate dateToFormat,
964 UChar* result,
965 int32_t resultLength,
966 UFieldPosition* position,
967 UErrorCode* status);
968
969 #ifndef U_HIDE_DRAFT_API
970
992 U_DRAFT int32_t U_EXPORT2
993 udat_formatCalendar( const UDateFormat* format,
994 UCalendar* calendar,
995 UChar* result,
996 int32_t capacity,
997 UFieldPosition* position,
998 UErrorCode* status);
999
1027 U_DRAFT int32_t U_EXPORT2
1028 udat_formatForFields( const UDateFormat* format,
1029 UDate dateToFormat,
1030 UChar* result,
1031 int32_t resultLength,
1032 UFieldPositionIterator* fpositer,
1033 UErrorCode* status);
1034
1065 U_DRAFT int32_t U_EXPORT2
1066 udat_formatCalendarForFields( const UDateFormat* format,
1067 UCalendar* calendar,
1068 UChar* result,
1069 int32_t capacity,
1070 UFieldPositionIterator* fpositer,
1071 UErrorCode* status);
1072
1073 #endif /* U_HIDE_DRAFT_API */
1074
1100 U_STABLE UDate U_EXPORT2
1101 udat_parse(const UDateFormat* format,
1102 const UChar* text,
1103 int32_t textLength,
1104 int32_t *parsePos,
1105 UErrorCode *status);
1106
1128 U_STABLE void U_EXPORT2
1129 udat_parseCalendar(const UDateFormat* format,
1130 UCalendar* calendar,
1131 const UChar* text,
1132 int32_t textLength,
1133 int32_t *parsePos,
1134 UErrorCode *status);
1135
1145 U_STABLE UBool U_EXPORT2
1146 udat_isLenient(const UDateFormat* fmt);
1147
1157 U_STABLE void U_EXPORT2
1158 udat_setLenient( UDateFormat* fmt,
1159 UBool isLenient);
1160
1170 U_STABLE const UCalendar* U_EXPORT2
1171 udat_getCalendar(const UDateFormat* fmt);
1172
1182 U_STABLE void U_EXPORT2
1183 udat_setCalendar( UDateFormat* fmt,
1184 const UCalendar* calendarToSet);
1185
1195 U_STABLE const UNumberFormat* U_EXPORT2
1196 udat_getNumberFormat(const UDateFormat* fmt);
1197
1198 #ifndef U_HIDE_DRAFT_API
1199
1208 U_DRAFT const UNumberFormat* U_EXPORT2
1209 udat_getNumberFormatForField(const UDateFormat* fmt, UChar field);
1210
1226 U_DRAFT void U_EXPORT2
1227 udat_adoptNumberFormatForFields( UDateFormat* fmt,
1228 const UChar* fields,
1229 UNumberFormat* numberFormatToSet,
1230 UErrorCode* status);
1231 #endif /* U_HIDE_DRAFT_API */
1232
1245 U_STABLE void U_EXPORT2
1246 udat_setNumberFormat( UDateFormat* fmt,
1247 const UNumberFormat* numberFormatToSet);
1248
1249 #ifndef U_HIDE_DRAFT_API
1250
1259 U_DRAFT void U_EXPORT2
1260 udat_adoptNumberFormat( UDateFormat* fmt,
1261 UNumberFormat* numberFormatToAdopt);
1262 #endif /* U_HIDE_DRAFT_API */
1263
1273 U_STABLE const char* U_EXPORT2
1274 udat_getAvailable(int32_t localeIndex);
1275
1284 U_STABLE int32_t U_EXPORT2
1285 udat_countAvailable(void);
1286
1297 U_STABLE UDate U_EXPORT2
1298 udat_get2DigitYearStart( const UDateFormat *fmt,
1299 UErrorCode *status);
1300
1311 U_STABLE void U_EXPORT2
1312 udat_set2DigitYearStart( UDateFormat *fmt,
1313 UDate d,
1314 UErrorCode *status);
1315
1328 U_STABLE int32_t U_EXPORT2
1329 udat_toPattern( const UDateFormat *fmt,
1330 UBool localized,
1331 UChar *result,
1332 int32_t resultLength,
1333 UErrorCode *status);
1334
1345 U_STABLE void U_EXPORT2
1346 udat_applyPattern( UDateFormat *format,
1347 UBool localized,
1348 const UChar *pattern,
1349 int32_t patternLength);
1350
1355 typedef enum UDateFormatSymbolType {
1357 UDAT_ERAS,
1359 UDAT_MONTHS,
1361 UDAT_SHORT_MONTHS,
1363 UDAT_WEEKDAYS,
1368 UDAT_SHORT_WEEKDAYS,
1370 UDAT_AM_PMS,
1372 UDAT_LOCALIZED_CHARS,
1374 UDAT_ERA_NAMES,
1376 UDAT_NARROW_MONTHS,
1378 UDAT_NARROW_WEEKDAYS,
1380 UDAT_STANDALONE_MONTHS,
1381 UDAT_STANDALONE_SHORT_MONTHS,
1382 UDAT_STANDALONE_NARROW_MONTHS,
1384 UDAT_STANDALONE_WEEKDAYS,
1389 UDAT_STANDALONE_SHORT_WEEKDAYS,
1391 UDAT_STANDALONE_NARROW_WEEKDAYS,
1393 UDAT_QUARTERS,
1395 UDAT_SHORT_QUARTERS,
1397 UDAT_STANDALONE_QUARTERS,
1398 UDAT_STANDALONE_SHORT_QUARTERS,
1406 UDAT_SHORTER_WEEKDAYS,
1411 UDAT_STANDALONE_SHORTER_WEEKDAYS
1412 #ifndef U_HIDE_DRAFT_API
1413 ,
1419 UDAT_CYCLIC_YEARS_WIDE,
1424 UDAT_CYCLIC_YEARS_ABBREVIATED,
1430 UDAT_CYCLIC_YEARS_NARROW,
1436 UDAT_ZODIAC_NAMES_WIDE,
1441 UDAT_ZODIAC_NAMES_ABBREVIATED,
1447 UDAT_ZODIAC_NAMES_NARROW
1448 #endif /* U_HIDE_DRAFT_API */
1449 } UDateFormatSymbolType;
1450
1451 struct UDateFormatSymbols;
1456 typedef struct UDateFormatSymbols UDateFormatSymbols;
1457
1474 U_STABLE int32_t U_EXPORT2
1475 udat_getSymbols(const UDateFormat *fmt,
1476 UDateFormatSymbolType type,
1477 int32_t symbolIndex,
1478 UChar *result,
1479 int32_t resultLength,
1480 UErrorCode *status);
1481
1494 U_STABLE int32_t U_EXPORT2
1495 udat_countSymbols( const UDateFormat *fmt,
1496 UDateFormatSymbolType type);
1497
1513 U_STABLE void U_EXPORT2
1514 udat_setSymbols( UDateFormat *format,
1515 UDateFormatSymbolType type,
1516 int32_t symbolIndex,
1517 UChar *value,
1518 int32_t valueLength,
1519 UErrorCode *status);
1520
1530 U_STABLE const char* U_EXPORT2
1531 udat_getLocaleByType(const UDateFormat *fmt,
1532 ULocDataLocaleType type,
1533 UErrorCode* status);
1534
1543 U_DRAFT void U_EXPORT2
1544 udat_setContext(UDateFormat* fmt, UDisplayContext value, UErrorCode* status);
1545
1555 U_STABLE UDisplayContext U_EXPORT2
1556 udat_getContext(const UDateFormat* fmt, UDisplayContextType type, UErrorCode* status);
1557
1558 #ifndef U_HIDE_INTERNAL_API
1559
1570 U_INTERNAL int32_t U_EXPORT2
1571 udat_toPatternRelativeDate(const UDateFormat *fmt,
1572 UChar *result,
1573 int32_t resultLength,
1574 UErrorCode *status);
1575
1587 U_INTERNAL int32_t U_EXPORT2
1588 udat_toPatternRelativeTime(const UDateFormat *fmt,
1589 UChar *result,
1590 int32_t resultLength,
1591 UErrorCode *status);
1592
1605 U_INTERNAL void U_EXPORT2
1606 udat_applyPatternRelative(UDateFormat *format,
1607 const UChar *datePattern,
1608 int32_t datePatternLength,
1609 const UChar *timePattern,
1610 int32_t timePatternLength,
1611 UErrorCode *status);
1612
1617 typedef UDateFormat* (U_EXPORT2 *UDateFormatOpener) (UDateFormatStyle timeStyle,
1618 UDateFormatStyle dateStyle,
1619 const char *locale,
1620 const UChar *tzID,
1621 int32_t tzIDLength,
1622 const UChar *pattern,
1623 int32_t patternLength,
1624 UErrorCode *status);
1625
1630 U_INTERNAL void U_EXPORT2
1631 udat_registerOpener(UDateFormatOpener opener, UErrorCode *status);
1632
1637 U_INTERNAL UDateFormatOpener U_EXPORT2
1638 udat_unregisterOpener(UDateFormatOpener opener, UErrorCode *status);
1639 #endif /* U_HIDE_INTERNAL_API */
1640
1641
1642 #endif /* #if !UCONFIG_NO_FORMATTING */
1643
1644 #endif