diff options
author | Job Bautista <jobbautista9@protonmail.com> | 2022-07-25 14:07:36 +0800 |
---|---|---|
committer | Job Bautista <jobbautista9@protonmail.com> | 2022-07-25 14:07:36 +0800 |
commit | 824c2f0d4012f8e718dcca5c3db9b796a7530008 (patch) | |
tree | af2af37f56790bd99566c5566fafef3ec6b266de /intl/icu | |
parent | 6542ca6bcdf836ee1fb82b75d77adb0e9604b97b (diff) | |
download | uxp-824c2f0d4012f8e718dcca5c3db9b796a7530008.tar.gz |
Issue #1969 - Implement Intl.RelativeTimeFormat.
Based on Mozilla bugs 1270140, 1504656, 1483545, and 1504334.
Took note of Mozilla bug 1379222 which changed GetPrototypeFromCallableConstructor
to GetPrototypeFromBuiltinConstructor.
There are many other changes I did myself since the initial implementation by
Mozilla wouldn't work with this codebase.
Diffstat (limited to 'intl/icu')
-rw-r--r-- | intl/icu/source/i18n/reldatefmt.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/intl/icu/source/i18n/reldatefmt.cpp b/intl/icu/source/i18n/reldatefmt.cpp index 1a4da0f0b9..85637cb456 100644 --- a/intl/icu/source/i18n/reldatefmt.cpp +++ b/intl/icu/source/i18n/reldatefmt.cpp @@ -162,14 +162,20 @@ const UnicodeString& RelativeDateTimeCacheData::getAbsoluteUnitString( URelativeDateTimeUnit unit, int32_t pastFutureIndex, int32_t pluralUnit) const { - int32_t style = fStyle; - do { - if (relativeUnitsFormatters[style][unit][pastFutureIndex][pluralUnit] != nullptr) { - return relativeUnitsFormatters[style][unit][pastFutureIndex][pluralUnit]; + while (true) { + int32_t style = fStyle; + do { + if (relativeUnitsFormatters[style][unit][pastFutureIndex][pluralUnit] != nullptr) { + return relativeUnitsFormatters[style][unit][pastFutureIndex][pluralUnit]; + } + style = fallBackCache[style]; + } while (style != -1); + + if (pluralUnit == StandardPlural::OTHER) { + return nullptr; // No formatter found. } - style = fallBackCache[style]; - } while (style != -1); - return nullptr; // No formatter found. + pluralUnit = StandardPlural::OTHER; + } } static UBool getStringWithFallback( |