Skip to content

Commit 0171107

Browse files
ryzokukengibson042
andcommitted
Improve frontmatter and test cases
Add more important test cases and improve the frontmatter to add more context from the spec. Co-authored-by: Richard Gibson <[email protected]>
1 parent 2663821 commit 0171107

File tree

1 file changed

+82
-4
lines changed

1 file changed

+82
-4
lines changed

test/intl402/DateTimeFormat/canonicalize-timezone.js

+82-4
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,94 @@
33
/*---
44
esid: sec-use-of-iana-time-zone-database
55
description: >
6-
ecma402#877 adds normative requirements for canonicalizing time zone names
7-
based on the rules laid down by CLDR and ICU in order to help improve the
8-
interoperability of implementations. This test verifies that the time zones
9-
are canonicalized correctly as per the specification.
6+
Primary and non-primary time zone identifiers must correspond with IANA Time
7+
Zone Database Zones and Link names, subject to explicit exceptions, and must
8+
direct time zone name canonicalization.
9+
info: |
10+
AvailableNamedTimeZoneIdentifiers ( )
11+
12+
1. Let _identifiers_ be a List containing the String value of each Zone or Link name in the IANA Time Zone Database.
13+
2. ...
14+
3. ...
15+
4. Let _result_ be a new empty List.
16+
5. For each element _identifier_ of _identifiers_, do
17+
a. Let _primary_ be _identifier_.
18+
b. If _identifier_ is a Link name in the IANA Time Zone Database and _identifier_ is not present in the “TZ” column of <code>zone.tab</code> of the IANA Time Zone Database, then
19+
i. Let _zone_ be the Zone name that _identifier_ resolves to, according to the rules for resolving Link names in the IANA Time Zone Database.
20+
ii. If _zone_ starts with *"Etc/"*, then
21+
1. Set _primary_ to _zone_.
22+
iii. Else,
23+
1. Let _identifierCountryCode_ be the <a href="https://www.iso.org/glossary-for-iso-3166.html">ISO 3166-1 Alpha-2</a> country code whose territory contains the geographical area corresponding to _identifier_.
24+
2. Let _zoneCountryCode_ be the ISO 3166-1 Alpha-2 country code whose territory contains the geographical area corresponding to _zone_.
25+
3. If _identifierCountryCode_ is _zoneCountryCode_, then
26+
a. Set _primary_ to _zone_.
27+
4. Else,
28+
a. Let _countryCodeLineCount_ be the number of lines in file <code>zone.tab</code> of the IANA Time Zone Database where the “country-code” column is _identifierCountryCode_.
29+
b. If _countryCodeLineCount_ is 1, then
30+
i. Let _countryCodeLine_ be the line in file <code>zone.tab</code> of the IANA Time Zone Database where the “country-code” column is _identifierCountryCode_.
31+
ii. Set _primary_ to the contents of the “TZ” column of _countryCodeLine_.
32+
c. Else,
33+
i. Let _backzone_ be *undefined*.
34+
ii. Let _backzoneLinkLines_ be the List of lines in the file <code>backzone</code> of the IANA Time Zone Database that start with either *"Link "* or *"#PACKRATLIST zone.tab Link "*.
35+
iii. ...
36+
iv. Assert: _backzone_ is not *undefined*.
37+
v. Set _primary_ to _backzone_.
38+
c. If _primary_ is one of *"Etc/UTC"*, *"Etc/GMT"*, or *"GMT"*, set _primary_ to *"UTC"*.
39+
d. ...
40+
e. Let _record_ be the Time Zone Identifier Record { [[Identifier]]: _identifier_, [[PrimaryIdentifier]]: _primary_ }.
41+
f. Append _record_ to _result_.
42+
6. ...
43+
7. Return _result_.
44+
45+
GetAvailableNamedTimeZoneIdentifier ( _timeZoneIdentifier_ )
46+
47+
1. For each element _record_ of AvailableNamedTimeZoneIdentifiers(), do
48+
a. If _record_.[[Identifier]] is an ASCII-case-insensitive match for _timeZoneIdentifier_, return record.
49+
2. Return ~empty~.
50+
51+
CreateDateTimeFormat ( _newTarget_, _locales_, _options_, _required_, _defaults_ )
52+
53+
29. If IsTimeZoneOffsetString(_timeZone_) is *true*, then
54+
...
55+
30. Else,
56+
a. Let _timeZoneIdentifierRecord_ be GetAvailableNamedTimeZoneIdentifier(_timeZone_).
57+
b. If _timeZoneIdentifierRecord_ is ~empty~, throw a RangeError exception.
58+
c. Set _timeZone_ to _timeZoneIdentifierRecord_.[[PrimaryIdentifier]].
1059
---*/
1160

1261
const timeZones = [
62+
// Europe/Prague is not a Link name.
1363
["Europe/Prague", "Europe/Prague"],
64+
65+
// `backward` identifies "Europe/Bratislava" as a Link name targeting "Europe/Prague":
66+
// Link Europe/Prague Europe/Bratislava
67+
// Europe/Bratislava's country code "SK" has only one time zone in `zone.tab`.
1468
["Europe/Bratislava", "Europe/Bratislava"],
69+
70+
// `backward` identifies "Australia/Canberra" as a Link targeting "Australia/Sydney":
71+
// Link Australia/Sydney Australia/Canberra
72+
// Both share the country code "AU".
73+
["Australia/Canberra", "Australia/Sydney"],
74+
75+
// `backward` identifies "Atlantic/Jan_Mayen" as a Link name targeting "Europe/Berlin".
76+
// Link Europe/Berlin Atlantic/Jan_Mayen
77+
// Atlantic/Jan_Mayen's country code "SJ" which has only one time zone in `zone.tab`.
1578
["Atlantic/Jan_Mayen", "Arctic/Longyearbyen"],
79+
80+
// `backward` identifies "Pacific/Truk" as a Link name targeting "Pacific/Port_Moresby":
81+
// Link Pacific/Port_Moresby Pacific/Truk #= Pacific/Chuuk
82+
// Pacific/Chuuk's country code "FM" has multiple time zones in `zone.tab`.
83+
// `backzone` identifies "Pacific/Truk" as a Link name targeting "Pacific/Chuuk":
84+
// Link Pacific/Chuuk Pacific/Truk
85+
["Pacific/Truk", "Pacific/Chuuk"],
86+
87+
// `backward` identifies "Etc/UCT" as a Link name targeting "Etc/UTC":
88+
// Link Etc/UTC Etc/UCT
89+
["Etc/UCT", "UTC"],
90+
91+
// `backward` identifies "Etc/GMT0" as a Link name targeting "Etc/GMT":
92+
// Link Etc/GMT Etc/GMT0
93+
["Etc/GMT0", "UTC"]
1694
];
1795

1896
for (const [timeZone, expected] of timeZones) {

0 commit comments

Comments
 (0)