4e18190e69
1. Location names with more than one underscores (e.g. Ho_Chi_Minh) didn't work because of the way capturing works with repeated patterns in RE. It's now supported by changing the RE to capture the whole string and splitting on '_' in the next step. 2. Adds support for location names with a hyphen 3. Adds support for timezone ids with three parts (e.g. American/Argentina/Buenos_Aires) 4. Adds special handling of 'au', 'es' and 'of' in zone ids. They need to be kept in lowercase. (see the full list at https://en.wikipedia.org/wiki/List_of_tz_database_time_zones ) 5. Adds regression tests for all the above and make the existing tests more robust against future ICU changes. ICU canonicalizes zone names to deprecated names, but it may change. ( http://bugs.icu-project.org/trac/ticket/12044 ) BUG=364374 LOG=Y Review URL: https://codereview.chromium.org/1529363005 Cr-Commit-Position: refs/heads/master@{#33097}
26 lines
1.3 KiB
JavaScript
26 lines
1.3 KiB
JavaScript
// 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.
|
|
|
|
if (this.Intl) {
|
|
// Normalizes Kat{h,}mandu (chromium:487322)
|
|
// According to the IANA timezone db, Kathmandu is the current canonical
|
|
// name, but ICU got it backward. To make this test robust against a future
|
|
// ICU change ( http://bugs.icu-project.org/trac/ticket/12044 ),
|
|
// just check that Kat(h)mandu is resolved identically.
|
|
df1 = new Intl.DateTimeFormat('en-US', {'timeZone': 'Asia/Katmandu'})
|
|
df2 = new Intl.DateTimeFormat('en-US', {'timeZone': 'Asia/Kathmandu'})
|
|
assertEquals(df1.resolvedOptions().timeZone, df2.resolvedOptions().timeZone);
|
|
|
|
// Normalizes Ulan_Bator to Ulaanbaatar. Unlike Kat(h)mandu, ICU got this
|
|
// right so that we make sure that Ulan_Bator is resolved to Ulaanbaatar.
|
|
df = new Intl.DateTimeFormat('en-US', {'timeZone': 'Asia/Ulaanbaatar'})
|
|
assertEquals('Asia/Ulaanbaatar', df.resolvedOptions().timeZone);
|
|
|
|
df = new Intl.DateTimeFormat('en-US', {'timeZone': 'Asia/Ulan_Bator'})
|
|
assertEquals('Asia/Ulaanbaatar', df.resolvedOptions().timeZone);
|
|
|
|
// Throws for unsupported time zones.
|
|
assertThrows(() => Intl.DateTimeFormat(undefined, {timeZone: 'Aurope/Paris'}));
|
|
}
|