Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update UTC time zone canonicalization to match proposal-canonical-tz #4336

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions test/intl402/DateTimeFormat/canonicalize-utc-timezone.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,33 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-createdatetimeformat
description: Tests that the time zone names "Etc/UTC", "Etc/GMT", and "GMT" all resolve to "UTC".
description: >
Tests that the time zone names "Etc/UTC", "Etc/GMT", and "GMT" are not
canonicalized to "UTC" in "resolvedOptions".
info: |
CreateDateTimeFormat ( dateTimeFormat, locales, options, required, default )

29. If IsTimeZoneOffsetString(timeZone) is true, then
30. If IsTimeZoneOffsetString(timeZone) is true, then
...
30. Else,
31. Else,
a. Let timeZoneIdentifierRecord be GetAvailableNamedTimeZoneIdentifier(timeZone).
...
c. Set timeZone to timeZoneIdentifierRecord.[[Identifier]].

GetAvailableNamedTimeZoneIdentifier ( timeZoneIdentifier )

...
5. For each element identifier of identifiers, do
...
c. If primary is one of "Etc/UTC", "Etc/GMT", or "GMT", set primary to "UTC".
1. For each element record of AvailableNamedTimeZoneIdentifiers(), do
a. If record.[[Identifier]] is an ASCII-case-insensitive match for
timeZoneIdentifier, return record.

features: [canonical-tz]
---*/

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

for (const timeZone of utcIdentifiers) {
assert.sameValue(new Intl.DateTimeFormat([], {timeZone}).resolvedOptions().timeZone, "UTC", "Time zone name " + timeZone + " not canonicalized to 'UTC'.");
assert.notSameValue(
new Intl.DateTimeFormat([], {timeZone}).resolvedOptions().timeZone,
"UTC",
"Time zone name " + timeZone + " should not be canonicalized to 'UTC'.");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2025 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.zoneddatetime.prototype.equals
description: >
Tests that the time zone names "Etc/UTC", "Etc/GMT", and "GMT" are equal to,
but not canonicalized to, "UTC".
info: |
Temporal.ZonedDateTime.prototype.equals ( other )

...
5. If TimeZoneEquals(zonedDateTime.[[TimeZone]], other.[[TimeZone]]) is false,
return false.

TimeZoneEquals ( one, two )

...
4.a. Let recordOne be GetAvailableNamedTimeZoneIdentifier(one).
b. Let recordTwo be GetAvailableNamedTimeZoneIdentifier(two).
c. If recordOne is not empty and recordTwo is not empty and
recordOne.[[PrimaryIdentifier]] is recordTwo.[[PrimaryIdentifier]],
return true.

features: [canonical-tz, Temporal]
---*/

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

for (const timeZone of utcIdentifiers) {
const dateTime = new Temporal.ZonedDateTime(0n, timeZone);
const utcDateTime = new Temporal.ZonedDateTime(0n, "UTC");
assert.notSameValue(dateTime.timeZoneId, utcDateTime.timeZoneId, `${timeZone} should not be canonicalized to UTC`);
assert(dateTime.equals(utcDateTime), `Time zone ${timeZone} should be equal to primary identifier UTC`);
}
Loading