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

Test that Intl.DateTimeFormat canonicalizes the timezones "Etc/GMT", "Etc/UTC", and "GMT" to "UTC" #4328

Merged
merged 2 commits into from
Nov 18, 2024
Merged
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
26 changes: 26 additions & 0 deletions test/intl402/DateTimeFormat/canonicalize-utc-timezone.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2024 Igalia, S.L. All rights reserved.
// 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".
info: |
CreateDateTimeFormat ( dateTimeFormat, locales, options, required, default )

29. If IsTimeZoneOffsetString(timeZone) is true, then
...
30. Else,
a. Let timeZoneIdentifierRecord be GetAvailableNamedTimeZoneIdentifier(timeZone).

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".
---*/

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'.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As of the Time Zone Canonicalization proposal which is stage 3, resolvedOptions().timeZone gives the case-regularized original identifier, not the primary identifier. I'll open a PR to fix this.

}
Loading