Skip to content

Commit bff3074

Browse files
littledanCommit bot
authored andcommitted
Allow ICU to normalize time zones
There's at least one case of a time zone alias: Asia/Kathmandu aliases Asia/Katmandu. ICU seems to normalize to the (deprecated) latter choice. V8 internationalization choked on this change; this patch interprets ICU's output more precisely and allows it. BUG=chromium:487322 R=jungshik,adamk LOG=Y Review URL: https://codereview.chromium.org/1509273007 Cr-Commit-Position: refs/heads/master@{#32769}
1 parent eb67f85 commit bff3074

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/js/i18n.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,7 @@ function initializeDateTimeFormat(dateFormat, locales, options) {
15741574
var formatter = %CreateDateTimeFormat(
15751575
requestedLocale, {skeleton: ldmlString, timeZone: tz}, resolved);
15761576

1577-
if (!IS_UNDEFINED(tz) && tz !== resolved.timeZone) {
1577+
if (resolved.timeZone === "Etc/Unknown") {
15781578
throw MakeRangeError(kUnsupportedTimeZone, tz);
15791579
}
15801580

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2015 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// Normalizes Kat{h,}mandu (chromium:487322)
6+
df = new Intl.DateTimeFormat('en-US', {'timeZone': 'Asia/Katmandu'})
7+
assertEquals('Asia/Katmandu', df.resolvedOptions().timeZone);
8+
9+
df = new Intl.DateTimeFormat('en-US', {'timeZone': 'Asia/Kathmandu'})
10+
assertEquals('Asia/Katmandu', df.resolvedOptions().timeZone);
11+
12+
// Throws for unsupported time zones.
13+
assertThrows(() => Intl.DateTimeFormat(undefined, {timeZone: 'Aurope/Paris'}));

0 commit comments

Comments
 (0)