forked from tc39/test262
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update UTC time zone canonicalization to match proposal-canonical-tz
The test for tc39/ecma402#724 (added in tc39#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.
- Loading branch information
Showing
2 changed files
with
50 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
test/intl402/Temporal/ZonedDateTime/prototype/equals/canonicalize-utc-timezone.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`); | ||
} |