OLD | NEW |
1 /* | 1 /* |
2 ******************************************************************************* | 2 ******************************************************************************* |
3 * Copyright (C) 1996-2013, International Business Machines | 3 * Copyright (C) 1996-2014, International Business Machines |
4 * Corporation and others. All Rights Reserved. | 4 * Corporation and others. All Rights Reserved. |
5 ******************************************************************************* | 5 ******************************************************************************* |
6 */ | 6 */ |
7 | 7 |
8 #include "unicode/utypes.h" | 8 #include "unicode/utypes.h" |
9 | 9 |
10 #if !UCONFIG_NO_FORMATTING | 10 #if !UCONFIG_NO_FORMATTING |
11 | 11 |
12 #include "unicode/udat.h" | 12 #include "unicode/udat.h" |
13 | 13 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 UCAL_WEEK_OF_MONTH, // UDAT_WEEK_OF_MONTH_FIELD = 13 | 60 UCAL_WEEK_OF_MONTH, // UDAT_WEEK_OF_MONTH_FIELD = 13 |
61 UCAL_AM_PM, // UDAT_AM_PM_FIELD = 14 | 61 UCAL_AM_PM, // UDAT_AM_PM_FIELD = 14 |
62 UCAL_HOUR, // UDAT_HOUR1_FIELD = 15 | 62 UCAL_HOUR, // UDAT_HOUR1_FIELD = 15 |
63 UCAL_HOUR, // UDAT_HOUR0_FIELD = 16 | 63 UCAL_HOUR, // UDAT_HOUR0_FIELD = 16 |
64 UCAL_ZONE_OFFSET, // UDAT_TIMEZONE_FIELD = 17 | 64 UCAL_ZONE_OFFSET, // UDAT_TIMEZONE_FIELD = 17 |
65 UCAL_YEAR_WOY, // UDAT_YEAR_WOY_FIELD = 18 | 65 UCAL_YEAR_WOY, // UDAT_YEAR_WOY_FIELD = 18 |
66 UCAL_DOW_LOCAL, // UDAT_DOW_LOCAL_FIELD = 19 | 66 UCAL_DOW_LOCAL, // UDAT_DOW_LOCAL_FIELD = 19 |
67 UCAL_EXTENDED_YEAR, // UDAT_EXTENDED_YEAR_FIELD = 20 | 67 UCAL_EXTENDED_YEAR, // UDAT_EXTENDED_YEAR_FIELD = 20 |
68 UCAL_JULIAN_DAY, // UDAT_JULIAN_DAY_FIELD = 21 | 68 UCAL_JULIAN_DAY, // UDAT_JULIAN_DAY_FIELD = 21 |
69 UCAL_MILLISECONDS_IN_DAY, // UDAT_MILLISECONDS_IN_DAY_FIELD = 22 | 69 UCAL_MILLISECONDS_IN_DAY, // UDAT_MILLISECONDS_IN_DAY_FIELD = 22 |
70 UCAL_ZONE_OFFSET, // UDAT_TIMEZONE_RFC_FIELD = 23 | 70 UCAL_ZONE_OFFSET, // UDAT_TIMEZONE_RFC_FIELD = 23 (also UCAL_DST_OF
FSET) |
71 // UCAL_DST_OFFSET also | 71 UCAL_ZONE_OFFSET, // UDAT_TIMEZONE_GENERIC_FIELD = 24 (also UCAL_DS
T_OFFSET) |
72 UCAL_ZONE_OFFSET, // UDAT_TIMEZONE_GENERIC_FIELD = 24 | |
73 UCAL_DOW_LOCAL, // UDAT_STANDALONE_DAY_FIELD = 25 | 72 UCAL_DOW_LOCAL, // UDAT_STANDALONE_DAY_FIELD = 25 |
74 UCAL_MONTH, // UDAT_STANDALONE_MONTH_FIELD = 26 | 73 UCAL_MONTH, // UDAT_STANDALONE_MONTH_FIELD = 26 |
75 UCAL_MONTH, // UDAT_QUARTER_FIELD = 27 | 74 UCAL_MONTH, // UDAT_QUARTER_FIELD = 27 |
76 UCAL_MONTH, // UDAT_STANDALONE_QUARTER_FIELD = 28 | 75 UCAL_MONTH, // UDAT_STANDALONE_QUARTER_FIELD = 28 |
77 UCAL_ZONE_OFFSET, // UDAT_TIMEZONE_SPECIAL_FIELD = 29 | 76 UCAL_ZONE_OFFSET, // UDAT_TIMEZONE_SPECIAL_FIELD = 29 (also UCAL_DS
T_OFFSET) |
78 UCAL_YEAR, // UDAT_YEAR_NAME_FIELD = 30 | 77 UCAL_YEAR, // UDAT_YEAR_NAME_FIELD = 30 |
79 UCAL_FIELD_COUNT, // UDAT_FIELD_COUNT = 31 | 78 UCAL_ZONE_OFFSET, // UDAT_TIMEZONE_LOCALIZED_GMT_OFFSET_FIELD = 31
(also UCAL_DST_OFFSET) |
| 79 UCAL_ZONE_OFFSET, // UDAT_TIMEZONE_ISO_FIELD = 32 (also UCAL_DST_OF
FSET) |
| 80 UCAL_ZONE_OFFSET, // UDAT_TIMEZONE_ISO_LOCAL_FIELD = 33 (also UCAL_
DST_OFFSET) |
| 81 UCAL_EXTENDED_YEAR, // UDAT_RELATED_YEAR_FIELD = 34 (not an exact mat
ch) |
| 82 UCAL_FIELD_COUNT, // UDAT_FIELD_COUNT = 35 |
80 // UCAL_IS_LEAP_MONTH is not the target of a mapping | 83 // UCAL_IS_LEAP_MONTH is not the target of a mapping |
81 }; | 84 }; |
82 | 85 |
83 U_CAPI UCalendarDateFields U_EXPORT2 | 86 U_CAPI UCalendarDateFields U_EXPORT2 |
84 udat_toCalendarDateField(UDateFormatField field) { | 87 udat_toCalendarDateField(UDateFormatField field) { |
85 return gDateFieldMapping[field]; | 88 return gDateFieldMapping[field]; |
86 } | 89 } |
87 | 90 |
88 /* For now- one opener. */ | 91 /* For now- one opener. */ |
89 static UDateFormatOpener gOpener = NULL; | 92 static UDateFormatOpener gOpener = NULL; |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 return ((DateFormat*)fmt)->isLenient(); | 303 return ((DateFormat*)fmt)->isLenient(); |
301 } | 304 } |
302 | 305 |
303 U_CAPI void U_EXPORT2 | 306 U_CAPI void U_EXPORT2 |
304 udat_setLenient( UDateFormat* fmt, | 307 udat_setLenient( UDateFormat* fmt, |
305 UBool isLenient) | 308 UBool isLenient) |
306 { | 309 { |
307 ((DateFormat*)fmt)->setLenient(isLenient); | 310 ((DateFormat*)fmt)->setLenient(isLenient); |
308 } | 311 } |
309 | 312 |
| 313 U_DRAFT UBool U_EXPORT2 |
| 314 udat_getBooleanAttribute(const UDateFormat* fmt, |
| 315 UDateFormatBooleanAttribute attr, |
| 316 UErrorCode* status) |
| 317 { |
| 318 if(U_FAILURE(*status)) return FALSE; |
| 319 return ((DateFormat*)fmt)->getBooleanAttribute(attr, *status); |
| 320 //return FALSE; |
| 321 } |
| 322 |
| 323 U_DRAFT void U_EXPORT2 |
| 324 udat_setBooleanAttribute(UDateFormat *fmt, |
| 325 UDateFormatBooleanAttribute attr, |
| 326 UBool newValue, |
| 327 UErrorCode* status) |
| 328 { |
| 329 if(U_FAILURE(*status)) return; |
| 330 ((DateFormat*)fmt)->setBooleanAttribute(attr, newValue, *status); |
| 331 } |
| 332 |
310 U_CAPI const UCalendar* U_EXPORT2 | 333 U_CAPI const UCalendar* U_EXPORT2 |
311 udat_getCalendar(const UDateFormat* fmt) | 334 udat_getCalendar(const UDateFormat* fmt) |
312 { | 335 { |
313 return (const UCalendar*) ((DateFormat*)fmt)->getCalendar(); | 336 return (const UCalendar*) ((DateFormat*)fmt)->getCalendar(); |
314 } | 337 } |
315 | 338 |
316 U_CAPI void U_EXPORT2 | 339 U_CAPI void U_EXPORT2 |
317 udat_setCalendar(UDateFormat* fmt, | 340 udat_setCalendar(UDateFormat* fmt, |
318 const UCalendar* calendarToSet) | 341 const UCalendar* calendarToSet) |
319 { | 342 { |
320 ((DateFormat*)fmt)->setCalendar(*((Calendar*)calendarToSet)); | 343 ((DateFormat*)fmt)->setCalendar(*((Calendar*)calendarToSet)); |
321 } | 344 } |
322 | 345 |
| 346 U_DRAFT const UNumberFormat* U_EXPORT2 |
| 347 udat_getNumberFormatForField(const UDateFormat* fmt, UChar field) |
| 348 { |
| 349 UErrorCode status = U_ZERO_ERROR; |
| 350 verifyIsSimpleDateFormat(fmt, &status); |
| 351 if (U_FAILURE(status)) return (const UNumberFormat*) ((DateFormat*)fmt)->get
NumberFormat(); |
| 352 return (const UNumberFormat*) ((SimpleDateFormat*)fmt)->getNumberFormatForFi
eld(field); |
| 353 } |
| 354 |
323 U_CAPI const UNumberFormat* U_EXPORT2 | 355 U_CAPI const UNumberFormat* U_EXPORT2 |
324 udat_getNumberFormat(const UDateFormat* fmt) | 356 udat_getNumberFormat(const UDateFormat* fmt) |
325 { | 357 { |
326 return (const UNumberFormat*) ((DateFormat*)fmt)->getNumberFormat(); | 358 return (const UNumberFormat*) ((DateFormat*)fmt)->getNumberFormat(); |
327 } | 359 } |
328 | 360 |
| 361 U_DRAFT void U_EXPORT2 |
| 362 udat_adoptNumberFormatForFields( UDateFormat* fmt, |
| 363 const UChar* fields, |
| 364 UNumberFormat* numberFormatToSet, |
| 365 UErrorCode* status) |
| 366 { |
| 367 verifyIsSimpleDateFormat(fmt, status); |
| 368 if (U_FAILURE(*status)) return; |
| 369 |
| 370 if (fields!=NULL) { |
| 371 UnicodeString overrideFields(fields); |
| 372 ((SimpleDateFormat*)fmt)->adoptNumberFormat(overrideFields, (NumberForma
t*)numberFormatToSet, *status); |
| 373 } |
| 374 } |
| 375 |
329 U_CAPI void U_EXPORT2 | 376 U_CAPI void U_EXPORT2 |
330 udat_setNumberFormat(UDateFormat* fmt, | 377 udat_setNumberFormat(UDateFormat* fmt, |
331 const UNumberFormat* numberFormatToSet) | 378 const UNumberFormat* numberFormatToSet) |
332 { | 379 { |
333 ((DateFormat*)fmt)->setNumberFormat(*((NumberFormat*)numberFormatToSet)); | 380 ((DateFormat*)fmt)->setNumberFormat(*((NumberFormat*)numberFormatToSet)); |
334 } | 381 } |
335 | 382 |
| 383 U_DRAFT void U_EXPORT2 |
| 384 udat_adoptNumberFormat( UDateFormat* fmt, |
| 385 UNumberFormat* numberFormatToAdopt) |
| 386 { |
| 387 ((DateFormat*)fmt)->adoptNumberFormat((NumberFormat*)numberFormatToAdopt); |
| 388 } |
| 389 |
336 U_CAPI const char* U_EXPORT2 | 390 U_CAPI const char* U_EXPORT2 |
337 udat_getAvailable(int32_t index) | 391 udat_getAvailable(int32_t index) |
338 { | 392 { |
339 return uloc_getAvailable(index); | 393 return uloc_getAvailable(index); |
340 } | 394 } |
341 | 395 |
342 U_CAPI int32_t U_EXPORT2 | 396 U_CAPI int32_t U_EXPORT2 |
343 udat_countAvailable() | 397 udat_countAvailable() |
344 { | 398 { |
345 return uloc_countAvailable(); | 399 return uloc_countAvailable(); |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 break; | 585 break; |
532 | 586 |
533 case UDAT_STANDALONE_QUARTERS: | 587 case UDAT_STANDALONE_QUARTERS: |
534 res = syms->getQuarters(count, DateFormatSymbols::STANDALONE, DateFormat
Symbols::WIDE); | 588 res = syms->getQuarters(count, DateFormatSymbols::STANDALONE, DateFormat
Symbols::WIDE); |
535 break; | 589 break; |
536 | 590 |
537 case UDAT_STANDALONE_SHORT_QUARTERS: | 591 case UDAT_STANDALONE_SHORT_QUARTERS: |
538 res = syms->getQuarters(count, DateFormatSymbols::STANDALONE, DateFormat
Symbols::ABBREVIATED); | 592 res = syms->getQuarters(count, DateFormatSymbols::STANDALONE, DateFormat
Symbols::ABBREVIATED); |
539 break; | 593 break; |
540 | 594 |
| 595 case UDAT_CYCLIC_YEARS_WIDE: |
| 596 res = syms->getYearNames(count, DateFormatSymbols::FORMAT, DateFormatSym
bols::WIDE); |
| 597 break; |
| 598 |
| 599 case UDAT_CYCLIC_YEARS_ABBREVIATED: |
| 600 res = syms->getYearNames(count, DateFormatSymbols::FORMAT, DateFormatSym
bols::ABBREVIATED); |
| 601 break; |
| 602 |
| 603 case UDAT_CYCLIC_YEARS_NARROW: |
| 604 res = syms->getYearNames(count, DateFormatSymbols::FORMAT, DateFormatSym
bols::NARROW); |
| 605 break; |
| 606 |
| 607 case UDAT_ZODIAC_NAMES_WIDE: |
| 608 res = syms->getZodiacNames(count, DateFormatSymbols::FORMAT, DateFormatS
ymbols::WIDE); |
| 609 break; |
| 610 |
| 611 case UDAT_ZODIAC_NAMES_ABBREVIATED: |
| 612 res = syms->getZodiacNames(count, DateFormatSymbols::FORMAT, DateFormatS
ymbols::ABBREVIATED); |
| 613 break; |
| 614 |
| 615 case UDAT_ZODIAC_NAMES_NARROW: |
| 616 res = syms->getZodiacNames(count, DateFormatSymbols::FORMAT, DateFormatS
ymbols::NARROW); |
| 617 break; |
| 618 |
541 } | 619 } |
542 | 620 |
543 if(index < count) { | 621 if(index < count) { |
544 return res[index].extract(result, resultLength, *status); | 622 return res[index].extract(result, resultLength, *status); |
545 } | 623 } |
546 return 0; | 624 return 0; |
547 } | 625 } |
548 | 626 |
549 // TODO: also needs an errorCode. | 627 // TODO: also needs an errorCode. |
550 U_CAPI int32_t U_EXPORT2 | 628 U_CAPI int32_t U_EXPORT2 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 break; | 723 break; |
646 | 724 |
647 case UDAT_STANDALONE_QUARTERS: | 725 case UDAT_STANDALONE_QUARTERS: |
648 syms->getQuarters(count, DateFormatSymbols::STANDALONE, DateFormatSymbol
s::WIDE); | 726 syms->getQuarters(count, DateFormatSymbols::STANDALONE, DateFormatSymbol
s::WIDE); |
649 break; | 727 break; |
650 | 728 |
651 case UDAT_STANDALONE_SHORT_QUARTERS: | 729 case UDAT_STANDALONE_SHORT_QUARTERS: |
652 syms->getQuarters(count, DateFormatSymbols::STANDALONE, DateFormatSymbol
s::ABBREVIATED); | 730 syms->getQuarters(count, DateFormatSymbols::STANDALONE, DateFormatSymbol
s::ABBREVIATED); |
653 break; | 731 break; |
654 | 732 |
| 733 case UDAT_CYCLIC_YEARS_WIDE: |
| 734 syms->getYearNames(count, DateFormatSymbols::FORMAT, DateFormatSymbols::
WIDE); |
| 735 break; |
| 736 |
| 737 case UDAT_CYCLIC_YEARS_ABBREVIATED: |
| 738 syms->getYearNames(count, DateFormatSymbols::FORMAT, DateFormatSymbols::
ABBREVIATED); |
| 739 break; |
| 740 |
| 741 case UDAT_CYCLIC_YEARS_NARROW: |
| 742 syms->getYearNames(count, DateFormatSymbols::FORMAT, DateFormatSymbols::
NARROW); |
| 743 break; |
| 744 |
| 745 case UDAT_ZODIAC_NAMES_WIDE: |
| 746 syms->getZodiacNames(count, DateFormatSymbols::FORMAT, DateFormatSymbols
::WIDE); |
| 747 break; |
| 748 |
| 749 case UDAT_ZODIAC_NAMES_ABBREVIATED: |
| 750 syms->getZodiacNames(count, DateFormatSymbols::FORMAT, DateFormatSymbols
::ABBREVIATED); |
| 751 break; |
| 752 |
| 753 case UDAT_ZODIAC_NAMES_NARROW: |
| 754 syms->getZodiacNames(count, DateFormatSymbols::FORMAT, DateFormatSymbols
::NARROW); |
| 755 break; |
| 756 |
655 } | 757 } |
656 | 758 |
657 return count; | 759 return count; |
658 } | 760 } |
659 | 761 |
660 U_NAMESPACE_BEGIN | 762 U_NAMESPACE_BEGIN |
661 | 763 |
662 /* | 764 /* |
663 * This DateFormatSymbolsSingleSetter class is a friend of DateFormatSymbols | 765 * This DateFormatSymbolsSingleSetter class is a friend of DateFormatSymbols |
664 * solely for the purpose of avoiding to clone the array of strings | 766 * solely for the purpose of avoiding to clone the array of strings |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 } | 936 } |
835 | 937 |
836 static void | 938 static void |
837 setStandaloneShortQuarter(DateFormatSymbols *syms, int32_t index, | 939 setStandaloneShortQuarter(DateFormatSymbols *syms, int32_t index, |
838 const UChar *value, int32_t valueLength, UErrorCode &errorCode) | 940 const UChar *value, int32_t valueLength, UErrorCode &errorCode) |
839 { | 941 { |
840 setSymbol(syms->fStandaloneShortQuarters, syms->fStandaloneShortQuarters
Count, index, value, valueLength, errorCode); | 942 setSymbol(syms->fStandaloneShortQuarters, syms->fStandaloneShortQuarters
Count, index, value, valueLength, errorCode); |
841 } | 943 } |
842 | 944 |
843 static void | 945 static void |
| 946 setShortYearNames(DateFormatSymbols *syms, int32_t index, |
| 947 const UChar *value, int32_t valueLength, UErrorCode &errorCode) |
| 948 { |
| 949 setSymbol(syms->fShortYearNames, syms->fShortYearNamesCount, index, valu
e, valueLength, errorCode); |
| 950 } |
| 951 |
| 952 static void |
| 953 setShortZodiacNames(DateFormatSymbols *syms, int32_t index, |
| 954 const UChar *value, int32_t valueLength, UErrorCode &errorCode) |
| 955 { |
| 956 setSymbol(syms->fShortZodiacNames, syms->fShortZodiacNamesCount, index,
value, valueLength, errorCode); |
| 957 } |
| 958 |
| 959 static void |
844 setAmPm(DateFormatSymbols *syms, int32_t index, | 960 setAmPm(DateFormatSymbols *syms, int32_t index, |
845 const UChar *value, int32_t valueLength, UErrorCode &errorCode) | 961 const UChar *value, int32_t valueLength, UErrorCode &errorCode) |
846 { | 962 { |
847 setSymbol(syms->fAmPms, syms->fAmPmsCount, index, value, valueLength, er
rorCode); | 963 setSymbol(syms->fAmPms, syms->fAmPmsCount, index, value, valueLength, er
rorCode); |
848 } | 964 } |
849 | 965 |
850 static void | 966 static void |
851 setLocalPatternChars(DateFormatSymbols *syms, | 967 setLocalPatternChars(DateFormatSymbols *syms, |
852 const UChar *value, int32_t valueLength, UErrorCode &errorCode) | 968 const UChar *value, int32_t valueLength, UErrorCode &errorCode) |
853 { | 969 { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 break; | 1060 break; |
945 | 1061 |
946 case UDAT_STANDALONE_QUARTERS: | 1062 case UDAT_STANDALONE_QUARTERS: |
947 DateFormatSymbolsSingleSetter::setStandaloneQuarter(syms, index, value,
valueLength, *status); | 1063 DateFormatSymbolsSingleSetter::setStandaloneQuarter(syms, index, value,
valueLength, *status); |
948 break; | 1064 break; |
949 | 1065 |
950 case UDAT_STANDALONE_SHORT_QUARTERS: | 1066 case UDAT_STANDALONE_SHORT_QUARTERS: |
951 DateFormatSymbolsSingleSetter::setStandaloneShortQuarter(syms, index, va
lue, valueLength, *status); | 1067 DateFormatSymbolsSingleSetter::setStandaloneShortQuarter(syms, index, va
lue, valueLength, *status); |
952 break; | 1068 break; |
953 | 1069 |
| 1070 case UDAT_CYCLIC_YEARS_ABBREVIATED: |
| 1071 DateFormatSymbolsSingleSetter::setShortYearNames(syms, index, value, val
ueLength, *status); |
| 1072 break; |
| 1073 |
| 1074 case UDAT_ZODIAC_NAMES_ABBREVIATED: |
| 1075 DateFormatSymbolsSingleSetter::setShortZodiacNames(syms, index, value, v
alueLength, *status); |
| 1076 break; |
| 1077 |
954 case UDAT_AM_PMS: | 1078 case UDAT_AM_PMS: |
955 DateFormatSymbolsSingleSetter::setAmPm(syms, index, value, valueLength,
*status); | 1079 DateFormatSymbolsSingleSetter::setAmPm(syms, index, value, valueLength,
*status); |
956 break; | 1080 break; |
957 | 1081 |
958 case UDAT_LOCALIZED_CHARS: | 1082 case UDAT_LOCALIZED_CHARS: |
959 DateFormatSymbolsSingleSetter::setLocalPatternChars(syms, value, valueLe
ngth, *status); | 1083 DateFormatSymbolsSingleSetter::setLocalPatternChars(syms, value, valueLe
ngth, *status); |
960 break; | 1084 break; |
961 | 1085 |
962 default: | 1086 default: |
963 *status = U_UNSUPPORTED_ERROR; | 1087 *status = U_UNSUPPORTED_ERROR; |
964 break; | 1088 break; |
965 | 1089 |
966 } | 1090 } |
967 } | 1091 } |
968 | 1092 |
969 U_CAPI const char* U_EXPORT2 | 1093 U_CAPI const char* U_EXPORT2 |
970 udat_getLocaleByType(const UDateFormat *fmt, | 1094 udat_getLocaleByType(const UDateFormat *fmt, |
971 ULocDataLocaleType type, | 1095 ULocDataLocaleType type, |
972 UErrorCode* status) | 1096 UErrorCode* status) |
973 { | 1097 { |
974 if (fmt == NULL) { | 1098 if (fmt == NULL) { |
975 if (U_SUCCESS(*status)) { | 1099 if (U_SUCCESS(*status)) { |
976 *status = U_ILLEGAL_ARGUMENT_ERROR; | 1100 *status = U_ILLEGAL_ARGUMENT_ERROR; |
977 } | 1101 } |
978 return NULL; | 1102 return NULL; |
979 } | 1103 } |
980 return ((Format*)fmt)->getLocaleID(type, *status); | 1104 return ((Format*)fmt)->getLocaleID(type, *status); |
981 } | 1105 } |
982 | 1106 |
983 | |
984 U_CAPI void U_EXPORT2 | 1107 U_CAPI void U_EXPORT2 |
985 udat_setContext(UDateFormat* fmt, UDisplayContext value, UErrorCode* status) | 1108 udat_setContext(UDateFormat* fmt, UDisplayContext value, UErrorCode* status) |
986 { | 1109 { |
987 verifyIsSimpleDateFormat(fmt, status); | |
988 if (U_FAILURE(*status)) { | 1110 if (U_FAILURE(*status)) { |
989 return; | 1111 return; |
990 } | 1112 } |
991 ((SimpleDateFormat*)fmt)->setContext(value, *status); | 1113 ((DateFormat*)fmt)->setContext(value, *status); |
| 1114 return; |
992 } | 1115 } |
993 | 1116 |
994 U_CAPI UDisplayContext U_EXPORT2 | 1117 U_CAPI UDisplayContext U_EXPORT2 |
995 udat_getContext(UDateFormat* fmt, UDisplayContextType type, UErrorCode* status) | 1118 udat_getContext(const UDateFormat* fmt, UDisplayContextType type, UErrorCode* st
atus) |
996 { | 1119 { |
997 verifyIsSimpleDateFormat(fmt, status); | |
998 if (U_FAILURE(*status)) { | 1120 if (U_FAILURE(*status)) { |
999 return (UDisplayContext)0; | 1121 return (UDisplayContext)0; |
1000 } | 1122 } |
1001 return ((SimpleDateFormat*)fmt)->getContext(type, *status); | 1123 return ((const DateFormat*)fmt)->getContext(type, *status); |
1002 } | 1124 } |
1003 | 1125 |
1004 | 1126 |
1005 /** | 1127 /** |
1006 * Verify that fmt is a RelativeDateFormat. Invalid error if not. | 1128 * Verify that fmt is a RelativeDateFormat. Invalid error if not. |
1007 * @param fmt the UDateFormat, definitely a DateFormat, maybe something else | 1129 * @param fmt the UDateFormat, definitely a DateFormat, maybe something else |
1008 * @param status error code, will be set to failure if there is a familure or th
e fmt is NULL. | 1130 * @param status error code, will be set to failure if there is a familure or th
e fmt is NULL. |
1009 */ | 1131 */ |
1010 static void verifyIsRelativeDateFormat(const UDateFormat* fmt, UErrorCode *statu
s) { | 1132 static void verifyIsRelativeDateFormat(const UDateFormat* fmt, UErrorCode *statu
s) { |
1011 if(U_SUCCESS(*status) && | 1133 if(U_SUCCESS(*status) && |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1062 UErrorCode *status) | 1184 UErrorCode *status) |
1063 { | 1185 { |
1064 verifyIsRelativeDateFormat(format, status); | 1186 verifyIsRelativeDateFormat(format, status); |
1065 if(U_FAILURE(*status)) return; | 1187 if(U_FAILURE(*status)) return; |
1066 const UnicodeString datePat((UBool)(datePatternLength == -1), datePattern, d
atePatternLength); | 1188 const UnicodeString datePat((UBool)(datePatternLength == -1), datePattern, d
atePatternLength); |
1067 const UnicodeString timePat((UBool)(timePatternLength == -1), timePattern, t
imePatternLength); | 1189 const UnicodeString timePat((UBool)(timePatternLength == -1), timePattern, t
imePatternLength); |
1068 ((RelativeDateFormat*)format)->applyPatterns(datePat, timePat, *status); | 1190 ((RelativeDateFormat*)format)->applyPatterns(datePat, timePat, *status); |
1069 } | 1191 } |
1070 | 1192 |
1071 #endif /* #if !UCONFIG_NO_FORMATTING */ | 1193 #endif /* #if !UCONFIG_NO_FORMATTING */ |
OLD | NEW |