Fix "japanese" and "chinese" calendar

Roll the icu to include the fix. The roll include previously
mistakenly filter out required resources.
Fix "japanese" under "ja" and calendar: "chinese" under "zh"
Depends on https://chromium-review.googlesource.com/c/chromium/deps/icu/+/2433166

This CL prepare for such landing:
1. Add test to show the correct result.
2. Wrap the number format static cast to DecimalFormat only if
   the concrete class is DecimalFormat. This is needed after the landing
   because the new resource enable other subclass of NumberFormat.
3. Change test to allow the additional numberingSystems.

Roll the the DEPS of chromium in
https://chromium-review.googlesource.com/c/chromium/src/+/2437820

Bug: v8:10960
Change-Id: Ib10b11862a093d1d487070f79556505bfc10bcc5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2432801
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70253}
This commit is contained in:
Frank Tang 2020-09-30 11:21:41 -07:00 committed by Commit Bot
parent 0e127b12e8
commit be3550bf70
4 changed files with 52 additions and 6 deletions

2
DEPS
View File

@ -86,7 +86,7 @@ deps = {
'third_party/depot_tools':
Var('chromium_url') + '/chromium/tools/depot_tools.git' + '@' + '991ead187c148de57990cbeecb9ad35767987a7c',
'third_party/icu':
Var('chromium_url') + '/chromium/deps/icu.git' + '@' + 'aef20f06d47ba76fdf13abcdb033e2a408b5a94d',
Var('chromium_url') + '/chromium/deps/icu.git' + '@' + 'aba3f0dfeeddc0c69730ec28ef423543b8a62693',
'third_party/instrumented_libraries':
Var('chromium_url') + '/chromium/src/third_party/instrumented_libraries.git' + '@' + '6ba978ccb754d270b6cd12da58c8269b617e4f6e',
'buildtools':

View File

@ -195,9 +195,12 @@ MaybeHandle<JSRelativeTimeFormat> JSRelativeTimeFormat::New(
}
}
icu::DecimalFormat* decimal_format =
static_cast<icu::DecimalFormat*>(number_format);
decimal_format->setMinimumGroupingDigits(-2);
if (number_format->getDynamicClassID() ==
icu::DecimalFormat::getStaticClassID()) {
icu::DecimalFormat* decimal_format =
static_cast<icu::DecimalFormat*>(number_format);
decimal_format->setMinimumGroupingDigits(-2);
}
// Change UDISPCTX_CAPITALIZATION_NONE to other values if
// ECMA402 later include option to change capitalization.

View File

@ -0,0 +1,38 @@
// Copyright 2020 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.
let d1 = new Date("2019-05-23T00:00");
// Ensure calendar: "japanese" under "ja" locale is correct.
assertEquals("R1/5/23", d1.toLocaleDateString(
"ja", {calendar: "japanese", timeZone:"UTC"}));
assertEquals("令和元年5月23日木曜日", d1.toLocaleDateString(
"ja", {calendar: "japanese", timeZone:"UTC", dateStyle: "full"}));
assertEquals("令和元年5月23日", d1.toLocaleDateString(
"ja", {calendar: "japanese", timeZone:"UTC", dateStyle: "long"}));
assertEquals("令和元年5月23日", d1.toLocaleDateString(
"ja", {calendar: "japanese", timeZone:"UTC", dateStyle: "medium"}));
assertEquals("R1/5/23", d1.toLocaleDateString(
"ja", {calendar: "japanese", timeZone:"UTC", dateStyle: "short"}));
// Ensure calendar: "chinese" under "zh" locale is correct.
d1 = new Date("2020-05-23T00:00");
assertEquals("2020年闰四月1", d1.toLocaleDateString(
"zh", {calendar: "chinese", timeZone:"UTC"}));
assertEquals("2020庚子年闰四月初一星期六", d1.toLocaleDateString(
"zh", {calendar: "chinese", timeZone:"UTC", dateStyle: "full"}));
assertEquals("2020庚子年闰四月初一", d1.toLocaleDateString(
"zh", {calendar: "chinese", timeZone:"UTC", dateStyle: "long"}));
assertEquals("2020年闰四月初一", d1.toLocaleDateString(
"zh", {calendar: "chinese", timeZone:"UTC", dateStyle: "medium"}));
assertEquals("2020/闰4/1", d1.toLocaleDateString(
"zh", {calendar: "chinese", timeZone:"UTC", dateStyle: "short"}));

View File

@ -11,11 +11,16 @@ const algorithmicNumberingSystems = [
algorithmicNumberingSystems.forEach(function(numberingSystem) {
let df = new Intl.DateTimeFormat("en", {dateStyle: "full", numberingSystem});
assertEquals("latn", df.resolvedOptions().numberingSystem);
if (df.resolvedOptions().numberingSystem != numberingSystem) {
assertEquals("latn", df.resolvedOptions().numberingSystem);
}
let df2 = new Intl.DateTimeFormat("en-u-nu-" + numberingSystem,
{dateStyle: "full"});
assertEquals("latn", df2.resolvedOptions().numberingSystem);
if (df2.resolvedOptions().numberingSystem != numberingSystem) {
assertEquals("latn", df2.resolvedOptions().numberingSystem);
}
// Just verify it won't crash
(new Date()).toLocaleString("en-u-nu-" + numberingSystem, {dateStyle: "full"});