From 43d1ac3a621c54350537f99809de9338e3fa9033 Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Fri, 22 Sep 2017 14:32:21 -0400 Subject: [PATCH] deps: backport bff3074 from V8 upstream Original commit message: 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} PR-URL: https://github.com/nodejs/node/pull/15562 Reviewed-By: James M Snell Reviewed-By: Ben Noordhuis Reviewed-By: Steven R Loomis --- deps/v8/include/v8-version.h | 2 +- deps/v8/src/i18n.js | 2 +- deps/v8/test/mjsunit/regress/regress-487322.js | 13 +++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 deps/v8/test/mjsunit/regress/regress-487322.js diff --git a/deps/v8/include/v8-version.h b/deps/v8/include/v8-version.h index 20282039beb27b..88682a0fa57b07 100644 --- a/deps/v8/include/v8-version.h +++ b/deps/v8/include/v8-version.h @@ -11,7 +11,7 @@ #define V8_MAJOR_VERSION 4 #define V8_MINOR_VERSION 5 #define V8_BUILD_NUMBER 103 -#define V8_PATCH_LEVEL 51 +#define V8_PATCH_LEVEL 52 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) diff --git a/deps/v8/src/i18n.js b/deps/v8/src/i18n.js index 79e988062e9425..c6675679dc9bbf 100644 --- a/deps/v8/src/i18n.js +++ b/deps/v8/src/i18n.js @@ -1562,7 +1562,7 @@ function initializeDateTimeFormat(dateFormat, locales, options) { var formatter = %CreateDateTimeFormat( requestedLocale, {skeleton: ldmlString, timeZone: tz}, resolved); - if (!IS_UNDEFINED(tz) && tz !== resolved.timeZone) { + if (resolved.timeZone === "Etc/Unknown") { throw MakeRangeError(kUnsupportedTimeZone, tz); } diff --git a/deps/v8/test/mjsunit/regress/regress-487322.js b/deps/v8/test/mjsunit/regress/regress-487322.js new file mode 100644 index 00000000000000..ae6da80e4473ba --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-487322.js @@ -0,0 +1,13 @@ +// Copyright 2015 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. + +// Normalizes Kat{h,}mandu (chromium:487322) +df = new Intl.DateTimeFormat('en-US', {'timeZone': 'Asia/Katmandu'}) +assertEquals('Asia/Katmandu', df.resolvedOptions().timeZone); + +df = new Intl.DateTimeFormat('en-US', {'timeZone': 'Asia/Kathmandu'}) +assertEquals('Asia/Katmandu', df.resolvedOptions().timeZone); + +// Throws for unsupported time zones. +assertThrows(() => Intl.DateTimeFormat(undefined, {timeZone: 'Aurope/Paris'}));