diff options
author | romankoshelev <romankoshelev@yandex-team.com> | 2023-08-09 20:07:20 +0300 |
---|---|---|
committer | romankoshelev <romankoshelev@yandex-team.com> | 2023-08-09 20:59:13 +0300 |
commit | fd82fb12fb45e71a02c628e45b12c50c0dd0d308 (patch) | |
tree | f582b79f9002ab1d083e9acda600dfb3551c47b6 /contrib/libs/icu/i18n/udat.cpp | |
parent | bf862ddf5c6178e1bb5e4fb3f7c61015deebe284 (diff) | |
download | ydb-fd82fb12fb45e71a02c628e45b12c50c0dd0d308.tar.gz |
Update ICU to 70.1
Diffstat (limited to 'contrib/libs/icu/i18n/udat.cpp')
-rw-r--r-- | contrib/libs/icu/i18n/udat.cpp | 65 |
1 files changed, 54 insertions, 11 deletions
diff --git a/contrib/libs/icu/i18n/udat.cpp b/contrib/libs/icu/i18n/udat.cpp index ab91bcff41..d9549d04c5 100644 --- a/contrib/libs/icu/i18n/udat.cpp +++ b/contrib/libs/icu/i18n/udat.cpp @@ -34,7 +34,7 @@ U_NAMESPACE_USE /** * Verify that fmt is a SimpleDateFormat. Invalid error if not. * @param fmt the UDateFormat, definitely a DateFormat, maybe something else - * @param status error code, will be set to failure if there is a familure or the fmt is NULL. + * @param status error code, will be set to failure if there is a failure or the fmt is NULL. */ static void verifyIsSimpleDateFormat(const UDateFormat* fmt, UErrorCode *status) { if(U_SUCCESS(*status) && @@ -82,19 +82,24 @@ static UCalendarDateFields gDateFieldMapping[] = { UCAL_ZONE_OFFSET, // UDAT_TIMEZONE_ISO_FIELD = 32 (also UCAL_DST_OFFSET) UCAL_ZONE_OFFSET, // UDAT_TIMEZONE_ISO_LOCAL_FIELD = 33 (also UCAL_DST_OFFSET) UCAL_EXTENDED_YEAR, // UDAT_RELATED_YEAR_FIELD = 34 (not an exact match) - UCAL_FIELD_COUNT, // UDAT_FIELD_COUNT = 35 + UCAL_FIELD_COUNT, // UDAT_AM_PM_MIDNIGHT_NOON_FIELD=35 (no match) + UCAL_FIELD_COUNT, // UDAT_FLEXIBLE_DAY_PERIOD_FIELD=36 (no match) + UCAL_FIELD_COUNT, // UDAT_TIME_SEPARATOR_FIELD = 37 (no match) + // UDAT_FIELD_COUNT = 38 as of ICU 67 // UCAL_IS_LEAP_MONTH is not the target of a mapping }; U_CAPI UCalendarDateFields U_EXPORT2 udat_toCalendarDateField(UDateFormatField field) { - return gDateFieldMapping[field]; + static_assert(UDAT_FIELD_COUNT == UPRV_LENGTHOF(gDateFieldMapping), + "UDateFormatField and gDateFieldMapping should have the same number of entries and be kept in sync."); + return (field >= UDAT_ERA_FIELD && field < UPRV_LENGTHOF(gDateFieldMapping))? gDateFieldMapping[field]: UCAL_FIELD_COUNT; } /* For now- one opener. */ static UDateFormatOpener gOpener = NULL; -U_INTERNAL void U_EXPORT2 +U_CAPI void U_EXPORT2 udat_registerOpener(UDateFormatOpener opener, UErrorCode *status) { if(U_FAILURE(*status)) return; @@ -107,7 +112,7 @@ udat_registerOpener(UDateFormatOpener opener, UErrorCode *status) umtx_unlock(NULL); } -U_INTERNAL UDateFormatOpener U_EXPORT2 +U_CAPI UDateFormatOpener U_EXPORT2 udat_unregisterOpener(UDateFormatOpener opener, UErrorCode *status) { if(U_FAILURE(*status)) return NULL; @@ -419,7 +424,7 @@ udat_setLenient( UDateFormat* fmt, ((DateFormat*)fmt)->setLenient(isLenient); } -U_DRAFT UBool U_EXPORT2 +U_CAPI UBool U_EXPORT2 udat_getBooleanAttribute(const UDateFormat* fmt, UDateFormatBooleanAttribute attr, UErrorCode* status) @@ -429,7 +434,7 @@ udat_getBooleanAttribute(const UDateFormat* fmt, //return FALSE; } -U_DRAFT void U_EXPORT2 +U_CAPI void U_EXPORT2 udat_setBooleanAttribute(UDateFormat *fmt, UDateFormatBooleanAttribute attr, UBool newValue, @@ -452,7 +457,7 @@ udat_setCalendar(UDateFormat* fmt, ((DateFormat*)fmt)->setCalendar(*((Calendar*)calendarToSet)); } -U_DRAFT const UNumberFormat* U_EXPORT2 +U_CAPI const UNumberFormat* U_EXPORT2 udat_getNumberFormatForField(const UDateFormat* fmt, UChar field) { UErrorCode status = U_ZERO_ERROR; @@ -467,7 +472,7 @@ udat_getNumberFormat(const UDateFormat* fmt) return (const UNumberFormat*) ((DateFormat*)fmt)->getNumberFormat(); } -U_DRAFT void U_EXPORT2 +U_CAPI void U_EXPORT2 udat_adoptNumberFormatForFields( UDateFormat* fmt, const UChar* fields, UNumberFormat* numberFormatToSet, @@ -489,7 +494,7 @@ udat_setNumberFormat(UDateFormat* fmt, ((DateFormat*)fmt)->setNumberFormat(*((NumberFormat*)numberFormatToSet)); } -U_DRAFT void U_EXPORT2 +U_CAPI void U_EXPORT2 udat_adoptNumberFormat( UDateFormat* fmt, UNumberFormat* numberFormatToAdopt) { @@ -699,6 +704,10 @@ udat_getSymbols(const UDateFormat *fmt, res = syms->getQuarters(count, DateFormatSymbols::FORMAT, DateFormatSymbols::ABBREVIATED); break; + case UDAT_NARROW_QUARTERS: + res = syms->getQuarters(count, DateFormatSymbols::FORMAT, DateFormatSymbols::NARROW); + break; + case UDAT_STANDALONE_QUARTERS: res = syms->getQuarters(count, DateFormatSymbols::STANDALONE, DateFormatSymbols::WIDE); break; @@ -707,6 +716,10 @@ udat_getSymbols(const UDateFormat *fmt, res = syms->getQuarters(count, DateFormatSymbols::STANDALONE, DateFormatSymbols::ABBREVIATED); break; + case UDAT_STANDALONE_NARROW_QUARTERS: + res = syms->getQuarters(count, DateFormatSymbols::STANDALONE, DateFormatSymbols::NARROW); + break; + case UDAT_CYCLIC_YEARS_WIDE: res = syms->getYearNames(count, DateFormatSymbols::FORMAT, DateFormatSymbols::WIDE); break; @@ -837,6 +850,10 @@ udat_countSymbols( const UDateFormat *fmt, syms->getQuarters(count, DateFormatSymbols::FORMAT, DateFormatSymbols::ABBREVIATED); break; + case UDAT_NARROW_QUARTERS: + syms->getQuarters(count, DateFormatSymbols::FORMAT, DateFormatSymbols::NARROW); + break; + case UDAT_STANDALONE_QUARTERS: syms->getQuarters(count, DateFormatSymbols::STANDALONE, DateFormatSymbols::WIDE); break; @@ -845,6 +862,10 @@ udat_countSymbols( const UDateFormat *fmt, syms->getQuarters(count, DateFormatSymbols::STANDALONE, DateFormatSymbols::ABBREVIATED); break; + case UDAT_STANDALONE_NARROW_QUARTERS: + syms->getQuarters(count, DateFormatSymbols::STANDALONE, DateFormatSymbols::NARROW); + break; + case UDAT_CYCLIC_YEARS_WIDE: syms->getYearNames(count, DateFormatSymbols::FORMAT, DateFormatSymbols::WIDE); break; @@ -1044,6 +1065,13 @@ public: } static void + setNarrowQuarter(DateFormatSymbols *syms, int32_t index, + const UChar *value, int32_t valueLength, UErrorCode &errorCode) + { + setSymbol(syms->fNarrowQuarters, syms->fNarrowQuartersCount, index, value, valueLength, errorCode); + } + + static void setStandaloneQuarter(DateFormatSymbols *syms, int32_t index, const UChar *value, int32_t valueLength, UErrorCode &errorCode) { @@ -1058,6 +1086,13 @@ public: } static void + setStandaloneNarrowQuarter(DateFormatSymbols *syms, int32_t index, + const UChar *value, int32_t valueLength, UErrorCode &errorCode) + { + setSymbol(syms->fStandaloneNarrowQuarters, syms->fStandaloneNarrowQuartersCount, index, value, valueLength, errorCode); + } + + static void setShortYearNames(DateFormatSymbols *syms, int32_t index, const UChar *value, int32_t valueLength, UErrorCode &errorCode) { @@ -1174,6 +1209,10 @@ udat_setSymbols( UDateFormat *format, DateFormatSymbolsSingleSetter::setShortQuarter(syms, index, value, valueLength, *status); break; + case UDAT_NARROW_QUARTERS: + DateFormatSymbolsSingleSetter::setNarrowQuarter(syms, index, value, valueLength, *status); + break; + case UDAT_STANDALONE_QUARTERS: DateFormatSymbolsSingleSetter::setStandaloneQuarter(syms, index, value, valueLength, *status); break; @@ -1182,6 +1221,10 @@ udat_setSymbols( UDateFormat *format, DateFormatSymbolsSingleSetter::setStandaloneShortQuarter(syms, index, value, valueLength, *status); break; + case UDAT_STANDALONE_NARROW_QUARTERS: + DateFormatSymbolsSingleSetter::setStandaloneNarrowQuarter(syms, index, value, valueLength, *status); + break; + case UDAT_CYCLIC_YEARS_ABBREVIATED: DateFormatSymbolsSingleSetter::setShortYearNames(syms, index, value, valueLength, *status); break; @@ -1242,7 +1285,7 @@ udat_getContext(const UDateFormat* fmt, UDisplayContextType type, UErrorCode* st /** * Verify that fmt is a RelativeDateFormat. Invalid error if not. * @param fmt the UDateFormat, definitely a DateFormat, maybe something else - * @param status error code, will be set to failure if there is a familure or the fmt is NULL. + * @param status error code, will be set to failure if there is a failure or the fmt is NULL. */ static void verifyIsRelativeDateFormat(const UDateFormat* fmt, UErrorCode *status) { if(U_SUCCESS(*status) && |