diff --git a/test/intl402/DateTimeFormat/canonicalize-utc-timezone.js b/test/intl402/DateTimeFormat/canonicalize-utc-timezone.js index 48fce061693..688de1cf4bc 100644 --- a/test/intl402/DateTimeFormat/canonicalize-utc-timezone.js +++ b/test/intl402/DateTimeFormat/canonicalize-utc-timezone.js @@ -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'."); } diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/equals/canonicalize-utc-timezone.js b/test/intl402/Temporal/ZonedDateTime/prototype/equals/canonicalize-utc-timezone.js new file mode 100644 index 00000000000..e4dc68bcc5b --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/equals/canonicalize-utc-timezone.js @@ -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`); +}