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.
This commit is contained in:
Job Bautista 2022-07-25 14:07:36 +08:00 committed by roytam1
commit 3e6cbc6af3
13 changed files with 669 additions and 20 deletions

View file

@ -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(