Skip to content

Commit 0055321

Browse files
committed
Update UTC time zone canonicalization to match proposal-canonical-tz
The test for tc39/ecma402#724 (added in #4328) didn't take the Time Zone Canonicalization proposal into account; but it should, because that proposal is stage 3. As of that proposal, the [[TimeZone]] slot of DateTimeFormat gets the case-regularized original identifier, no longer the primary identifier. So the resolvedOptions().timeZone property also no longer returns the primary identifier.
1 parent 5f98e1d commit 0055321

File tree

2 files changed

+50
-8
lines changed

2 files changed

+50
-8
lines changed

test/intl402/DateTimeFormat/canonicalize-utc-timezone.js

+16-8
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,33 @@
22
// This code is governed by the BSD license found in the LICENSE file.
33
/*---
44
esid: sec-createdatetimeformat
5-
description: Tests that the time zone names "Etc/UTC", "Etc/GMT", and "GMT" all resolve to "UTC".
5+
description: >
6+
Tests that the time zone names "Etc/UTC", "Etc/GMT", and "GMT" are not
7+
canonicalized to "UTC" in "resolvedOptions".
68
info: |
79
CreateDateTimeFormat ( dateTimeFormat, locales, options, required, default )
810
9-
29. If IsTimeZoneOffsetString(timeZone) is true, then
11+
30. If IsTimeZoneOffsetString(timeZone) is true, then
1012
...
11-
30. Else,
13+
31. Else,
1214
a. Let timeZoneIdentifierRecord be GetAvailableNamedTimeZoneIdentifier(timeZone).
15+
...
16+
c. Set timeZone to timeZoneIdentifierRecord.[[Identifier]].
1317
1418
GetAvailableNamedTimeZoneIdentifier ( timeZoneIdentifier )
1519
16-
...
17-
5. For each element identifier of identifiers, do
18-
...
19-
c. If primary is one of "Etc/UTC", "Etc/GMT", or "GMT", set primary to "UTC".
20+
1. For each element record of AvailableNamedTimeZoneIdentifiers(), do
21+
a. If record.[[Identifier]] is an ASCII-case-insensitive match for
22+
timeZoneIdentifier, return record.
23+
24+
features: [canonical-tz]
2025
---*/
2126

2227
const utcIdentifiers = ["Etc/GMT", "Etc/UTC", "GMT"];
2328

2429
for (const timeZone of utcIdentifiers) {
25-
assert.sameValue(new Intl.DateTimeFormat([], {timeZone}).resolvedOptions().timeZone, "UTC", "Time zone name " + timeZone + " not canonicalized to 'UTC'.");
30+
assert.notSameValue(
31+
new Intl.DateTimeFormat([], {timeZone}).resolvedOptions().timeZone,
32+
"UTC",
33+
"Time zone name " + timeZone + " should not be canonicalized to 'UTC'.");
2634
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2025 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
/*---
4+
esid: sec-temporal.zoneddatetime.prototype.equals
5+
description: >
6+
Tests that the time zone names "Etc/UTC", "Etc/GMT", and "GMT" are equal to,
7+
but not canonicalized to, "UTC".
8+
info: |
9+
Temporal.ZonedDateTime.prototype.equals ( other )
10+
11+
...
12+
5. If TimeZoneEquals(zonedDateTime.[[TimeZone]], other.[[TimeZone]]) is false,
13+
return false.
14+
15+
TimeZoneEquals ( one, two )
16+
17+
...
18+
4.a. Let recordOne be GetAvailableNamedTimeZoneIdentifier(one).
19+
b. Let recordTwo be GetAvailableNamedTimeZoneIdentifier(two).
20+
c. If recordOne is not empty and recordTwo is not empty and
21+
recordOne.[[PrimaryIdentifier]] is recordTwo.[[PrimaryIdentifier]],
22+
return true.
23+
24+
features: [canonical-tz, Temporal]
25+
---*/
26+
27+
const utcIdentifiers = ["Etc/GMT", "Etc/UTC", "GMT"];
28+
29+
for (const timeZone of utcIdentifiers) {
30+
const dateTime = new Temporal.ZonedDateTime(0n, timeZone);
31+
const utcDateTime = new Temporal.ZonedDateTime(0n, "UTC");
32+
assert.notSameValue(dateTime.timeZoneId, utcDateTime.timeZoneId, `${timeZone} should not be canonicalized to UTC`);
33+
assert(dateTime.equals(utcDateTime), `Time zone ${timeZone} should be equal to primary identifier UTC`);
34+
}

0 commit comments

Comments
 (0)