[Intl] Implement ECMA402 PR 349 and 351
It is controlled by flag harmony_intl_other_calendars. But this is also pretty intern-dependent with harmony_intl_add_calendar_numbering_system and should be launched all together to be meaningful. https://github.com/tc39/ecma402/pull/349/ #349 Normative: Allow calendar to determine choice of pattern https://github.com/tc39/ecma402/pull/351 #351 Normative: Permit relatedYear and yearName in output Bug: v8:9155 Change-Id: I67cd6bba6276bbb995186a9fe6202429d724ba61 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1588401 Reviewed-by: Jakob Kummerow <jkummerow@chromium.org> Commit-Queue: Frank Tang <ftang@chromium.org> Cr-Commit-Position: refs/heads/master@{#63972}
This commit is contained in:
parent
2b8dab42e5
commit
aad8c7f81b
@ -212,9 +212,10 @@ DEFINE_IMPLICATION(harmony_import_meta, harmony_dynamic_import)
|
||||
V(harmony_top_level_await, "harmony top level await")
|
||||
|
||||
#ifdef V8_INTL_SUPPORT
|
||||
#define HARMONY_INPROGRESS(V) \
|
||||
HARMONY_INPROGRESS_BASE(V) \
|
||||
V(harmony_intl_dateformat_quarter, "Add quarter option to DateTimeFormat")
|
||||
#define HARMONY_INPROGRESS(V) \
|
||||
HARMONY_INPROGRESS_BASE(V) \
|
||||
V(harmony_intl_dateformat_quarter, "Add quarter option to DateTimeFormat") \
|
||||
V(harmony_intl_other_calendars, "DateTimeFormat other calendars")
|
||||
#else
|
||||
#define HARMONY_INPROGRESS(V) HARMONY_INPROGRESS_BASE(V)
|
||||
#endif
|
||||
|
@ -4315,6 +4315,7 @@ EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_intl_dateformat_day_period)
|
||||
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(
|
||||
harmony_intl_dateformat_fractional_second_digits)
|
||||
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_intl_dateformat_quarter)
|
||||
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_intl_other_calendars)
|
||||
#endif // V8_INTL_SUPPORT
|
||||
|
||||
#undef EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE
|
||||
|
@ -82,6 +82,7 @@
|
||||
V(_, plusSign_string, "plusSign") \
|
||||
V(_, quarter_string, "quarter") \
|
||||
V(_, region_string, "region") \
|
||||
V(_, relatedYear_string, "relatedYear") \
|
||||
V(_, scientific_string, "scientific") \
|
||||
V(_, second_string, "second") \
|
||||
V(_, segment_string, "segment") \
|
||||
@ -107,7 +108,8 @@
|
||||
V(_, unit_string, "unit") \
|
||||
V(_, unitDisplay_string, "unitDisplay") \
|
||||
V(_, weekday_string, "weekday") \
|
||||
V(_, year_string, "year")
|
||||
V(_, year_string, "year") \
|
||||
V(_, yearName_string, "yearName")
|
||||
#else // V8_INTL_SUPPORT
|
||||
#define INTERNALIZED_STRING_LIST_GENERATOR_INTL(V, _)
|
||||
#endif // V8_INTL_SUPPORT
|
||||
|
@ -1186,7 +1186,8 @@ class DateTimePatternGeneratorCache {
|
||||
public:
|
||||
// Return a clone copy that the caller have to free.
|
||||
icu::DateTimePatternGenerator* CreateGenerator(const icu::Locale& locale) {
|
||||
std::string key(locale.getBaseName());
|
||||
std::string key(FLAG_harmony_intl_other_calendars ? locale.getName()
|
||||
: locale.getBaseName());
|
||||
base::MutexGuard guard(&mutex_);
|
||||
auto it = map_.find(key);
|
||||
if (it != map_.end()) {
|
||||
@ -1194,7 +1195,8 @@ class DateTimePatternGeneratorCache {
|
||||
}
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
map_[key].reset(icu::DateTimePatternGenerator::createInstance(
|
||||
icu::Locale(key.c_str()), status));
|
||||
FLAG_harmony_intl_other_calendars ? locale : icu::Locale(key.c_str()),
|
||||
status));
|
||||
// Fallback to use "root".
|
||||
if (U_FAILURE(status)) {
|
||||
status = U_ZERO_ERROR;
|
||||
@ -1580,11 +1582,12 @@ Handle<String> IcuDateFieldIdToDateType(int32_t field_id, Isolate* isolate) {
|
||||
return isolate->factory()->literal_string();
|
||||
case UDAT_YEAR_FIELD:
|
||||
case UDAT_EXTENDED_YEAR_FIELD:
|
||||
case UDAT_YEAR_NAME_FIELD:
|
||||
return isolate->factory()->year_string();
|
||||
case UDAT_QUARTER_FIELD:
|
||||
case UDAT_STANDALONE_QUARTER_FIELD:
|
||||
return isolate->factory()->quarter_string();
|
||||
case UDAT_YEAR_NAME_FIELD:
|
||||
return isolate->factory()->yearName_string();
|
||||
case UDAT_MONTH_FIELD:
|
||||
case UDAT_STANDALONE_MONTH_FIELD:
|
||||
return isolate->factory()->month_string();
|
||||
@ -1619,6 +1622,8 @@ Handle<String> IcuDateFieldIdToDateType(int32_t field_id, Isolate* isolate) {
|
||||
return isolate->factory()->era_string();
|
||||
case UDAT_FRACTIONAL_SECOND_FIELD:
|
||||
return isolate->factory()->fractionalSecond_string();
|
||||
case UDAT_RELATED_YEAR_FIELD:
|
||||
return isolate->factory()->relatedYear_string();
|
||||
default:
|
||||
// Other UDAT_*_FIELD's cannot show up because there is no way to specify
|
||||
// them via options of Intl.DateTimeFormat.
|
||||
|
14
test/intl/date-format/related-year.js
Normal file
14
test/intl/date-format/related-year.js
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright 2019 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-intl-other-calendars
|
||||
// Test it will output relatedYear and yearName
|
||||
|
||||
let df = new Intl.DateTimeFormat("zh-u-ca-chinese", {year: "numeric"})
|
||||
let date = new Date(2019, 5, 1);
|
||||
assertEquals("2019己亥年", df.format(date));
|
||||
assertEquals([{type: "relatedYear", value: "2019"},
|
||||
{type: "yearName", value: "己亥"},
|
||||
{type: "literal", value: "年"}],
|
||||
df.formatToParts(date));
|
@ -291,54 +291,54 @@ KNOWN_MAPS = {
|
||||
("read_only_space", 0x023a9): (87, "EnumCacheMap"),
|
||||
("read_only_space", 0x02449): (82, "ArrayBoilerplateDescriptionMap"),
|
||||
("read_only_space", 0x02639): (90, "InterceptorInfoMap"),
|
||||
("read_only_space", 0x04f59): (77, "AccessCheckInfoMap"),
|
||||
("read_only_space", 0x04fa9): (78, "AccessorInfoMap"),
|
||||
("read_only_space", 0x04ff9): (79, "AccessorPairMap"),
|
||||
("read_only_space", 0x05049): (80, "AliasedArgumentsEntryMap"),
|
||||
("read_only_space", 0x05099): (81, "AllocationMementoMap"),
|
||||
("read_only_space", 0x050e9): (83, "AsmWasmDataMap"),
|
||||
("read_only_space", 0x05139): (84, "AsyncGeneratorRequestMap"),
|
||||
("read_only_space", 0x05189): (85, "ClassPositionsMap"),
|
||||
("read_only_space", 0x051d9): (86, "DebugInfoMap"),
|
||||
("read_only_space", 0x05229): (88, "FunctionTemplateInfoMap"),
|
||||
("read_only_space", 0x05279): (89, "FunctionTemplateRareDataMap"),
|
||||
("read_only_space", 0x052c9): (91, "InterpreterDataMap"),
|
||||
("read_only_space", 0x05319): (92, "ObjectTemplateInfoMap"),
|
||||
("read_only_space", 0x05369): (93, "PromiseCapabilityMap"),
|
||||
("read_only_space", 0x053b9): (94, "PromiseReactionMap"),
|
||||
("read_only_space", 0x05409): (95, "PrototypeInfoMap"),
|
||||
("read_only_space", 0x05459): (96, "ScriptMap"),
|
||||
("read_only_space", 0x054a9): (97, "SourcePositionTableWithFrameCacheMap"),
|
||||
("read_only_space", 0x054f9): (98, "SourceTextModuleInfoEntryMap"),
|
||||
("read_only_space", 0x05549): (99, "StackFrameInfoMap"),
|
||||
("read_only_space", 0x05599): (100, "StackTraceFrameMap"),
|
||||
("read_only_space", 0x055e9): (101, "TemplateObjectDescriptionMap"),
|
||||
("read_only_space", 0x05639): (102, "Tuple2Map"),
|
||||
("read_only_space", 0x05689): (103, "Tuple3Map"),
|
||||
("read_only_space", 0x056d9): (104, "WasmCapiFunctionDataMap"),
|
||||
("read_only_space", 0x05729): (105, "WasmDebugInfoMap"),
|
||||
("read_only_space", 0x05779): (106, "WasmExceptionTagMap"),
|
||||
("read_only_space", 0x057c9): (107, "WasmExportedFunctionDataMap"),
|
||||
("read_only_space", 0x05819): (108, "WasmIndirectFunctionTableMap"),
|
||||
("read_only_space", 0x05869): (109, "WasmJSFunctionDataMap"),
|
||||
("read_only_space", 0x058b9): (110, "CallableTaskMap"),
|
||||
("read_only_space", 0x05909): (111, "CallbackTaskMap"),
|
||||
("read_only_space", 0x05959): (112, "PromiseFulfillReactionJobTaskMap"),
|
||||
("read_only_space", 0x059a9): (113, "PromiseRejectReactionJobTaskMap"),
|
||||
("read_only_space", 0x059f9): (114, "PromiseResolveThenableJobTaskMap"),
|
||||
("read_only_space", 0x05a49): (115, "InternalClassMap"),
|
||||
("read_only_space", 0x05a99): (116, "SmiPairMap"),
|
||||
("read_only_space", 0x05ae9): (117, "SmiBoxMap"),
|
||||
("read_only_space", 0x05b39): (118, "SortStateMap"),
|
||||
("read_only_space", 0x05b89): (121, "AllocationSiteWithWeakNextMap"),
|
||||
("read_only_space", 0x05bd9): (121, "AllocationSiteWithoutWeakNextMap"),
|
||||
("read_only_space", 0x05c29): (156, "LoadHandler1Map"),
|
||||
("read_only_space", 0x05c79): (156, "LoadHandler2Map"),
|
||||
("read_only_space", 0x05cc9): (156, "LoadHandler3Map"),
|
||||
("read_only_space", 0x05d19): (164, "StoreHandler0Map"),
|
||||
("read_only_space", 0x05d69): (164, "StoreHandler1Map"),
|
||||
("read_only_space", 0x05db9): (164, "StoreHandler2Map"),
|
||||
("read_only_space", 0x05e09): (164, "StoreHandler3Map"),
|
||||
("read_only_space", 0x04f91): (77, "AccessCheckInfoMap"),
|
||||
("read_only_space", 0x04fe1): (78, "AccessorInfoMap"),
|
||||
("read_only_space", 0x05031): (79, "AccessorPairMap"),
|
||||
("read_only_space", 0x05081): (80, "AliasedArgumentsEntryMap"),
|
||||
("read_only_space", 0x050d1): (81, "AllocationMementoMap"),
|
||||
("read_only_space", 0x05121): (83, "AsmWasmDataMap"),
|
||||
("read_only_space", 0x05171): (84, "AsyncGeneratorRequestMap"),
|
||||
("read_only_space", 0x051c1): (85, "ClassPositionsMap"),
|
||||
("read_only_space", 0x05211): (86, "DebugInfoMap"),
|
||||
("read_only_space", 0x05261): (88, "FunctionTemplateInfoMap"),
|
||||
("read_only_space", 0x052b1): (89, "FunctionTemplateRareDataMap"),
|
||||
("read_only_space", 0x05301): (91, "InterpreterDataMap"),
|
||||
("read_only_space", 0x05351): (92, "ObjectTemplateInfoMap"),
|
||||
("read_only_space", 0x053a1): (93, "PromiseCapabilityMap"),
|
||||
("read_only_space", 0x053f1): (94, "PromiseReactionMap"),
|
||||
("read_only_space", 0x05441): (95, "PrototypeInfoMap"),
|
||||
("read_only_space", 0x05491): (96, "ScriptMap"),
|
||||
("read_only_space", 0x054e1): (97, "SourcePositionTableWithFrameCacheMap"),
|
||||
("read_only_space", 0x05531): (98, "SourceTextModuleInfoEntryMap"),
|
||||
("read_only_space", 0x05581): (99, "StackFrameInfoMap"),
|
||||
("read_only_space", 0x055d1): (100, "StackTraceFrameMap"),
|
||||
("read_only_space", 0x05621): (101, "TemplateObjectDescriptionMap"),
|
||||
("read_only_space", 0x05671): (102, "Tuple2Map"),
|
||||
("read_only_space", 0x056c1): (103, "Tuple3Map"),
|
||||
("read_only_space", 0x05711): (104, "WasmCapiFunctionDataMap"),
|
||||
("read_only_space", 0x05761): (105, "WasmDebugInfoMap"),
|
||||
("read_only_space", 0x057b1): (106, "WasmExceptionTagMap"),
|
||||
("read_only_space", 0x05801): (107, "WasmExportedFunctionDataMap"),
|
||||
("read_only_space", 0x05851): (108, "WasmIndirectFunctionTableMap"),
|
||||
("read_only_space", 0x058a1): (109, "WasmJSFunctionDataMap"),
|
||||
("read_only_space", 0x058f1): (110, "CallableTaskMap"),
|
||||
("read_only_space", 0x05941): (111, "CallbackTaskMap"),
|
||||
("read_only_space", 0x05991): (112, "PromiseFulfillReactionJobTaskMap"),
|
||||
("read_only_space", 0x059e1): (113, "PromiseRejectReactionJobTaskMap"),
|
||||
("read_only_space", 0x05a31): (114, "PromiseResolveThenableJobTaskMap"),
|
||||
("read_only_space", 0x05a81): (115, "InternalClassMap"),
|
||||
("read_only_space", 0x05ad1): (116, "SmiPairMap"),
|
||||
("read_only_space", 0x05b21): (117, "SmiBoxMap"),
|
||||
("read_only_space", 0x05b71): (118, "SortStateMap"),
|
||||
("read_only_space", 0x05bc1): (121, "AllocationSiteWithWeakNextMap"),
|
||||
("read_only_space", 0x05c11): (121, "AllocationSiteWithoutWeakNextMap"),
|
||||
("read_only_space", 0x05c61): (156, "LoadHandler1Map"),
|
||||
("read_only_space", 0x05cb1): (156, "LoadHandler2Map"),
|
||||
("read_only_space", 0x05d01): (156, "LoadHandler3Map"),
|
||||
("read_only_space", 0x05d51): (164, "StoreHandler0Map"),
|
||||
("read_only_space", 0x05da1): (164, "StoreHandler1Map"),
|
||||
("read_only_space", 0x05df1): (164, "StoreHandler2Map"),
|
||||
("read_only_space", 0x05e41): (164, "StoreHandler3Map"),
|
||||
("map_space", 0x00121): (1057, "ExternalMap"),
|
||||
("map_space", 0x00171): (1073, "JSMessageObjectMap"),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user