Add test case for non-continental time zones

Adds a test that verifies that Intl.supportedValuesOf('timeZones')
includes those timezones those don't correspond to any continent. This
includes the oceanic Etc/* timezones and UTC.

Fixes: https://github.com/tc39/ecma402/issues/778
This commit is contained in:
Ujjwal Sharma 2025-03-27 16:46:02 +01:00 committed by Ms2ger
parent 6e311e4fb2
commit 4ba104a21c

View File

@ -0,0 +1,59 @@
// Copyright 2025 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-availableprimarytimezoneidentifiers
description: >
AvailablePrimaryTimeZoneIdentifiers doesn't perform any kind of filtering on
the time zone IDs returned therefore time zone IDs for time zones that don't
correspond to any continent like the Etc/* timezones as well as UTC should be
included in this list.
info: |
6.5.3 AvailablePrimaryTimeZoneIdentifiers ( )
1. Let records be AvailableNamedTimeZoneIdentifiers().
2. Let result be a new empty List.
3. For each element timeZoneIdentifierRecord of records, do
a. If timeZoneIdentifierRecord.[[Identifier]] is timeZoneIdentifierRecord.[[PrimaryIdentifier]], then
i. Append timeZoneIdentifierRecord.[[Identifier]] to result.
4. Return result.
features: [Intl-enumeration]
---*/
const nonContinentalTimeZones = [
"Etc/GMT+1",
"Etc/GMT+2",
"Etc/GMT+3",
"Etc/GMT+4",
"Etc/GMT+5",
"Etc/GMT+6",
"Etc/GMT+7",
"Etc/GMT+8",
"Etc/GMT+9",
"Etc/GMT+10",
"Etc/GMT+11",
"Etc/GMT+12",
"Etc/GMT-1",
"Etc/GMT-2",
"Etc/GMT-3",
"Etc/GMT-4",
"Etc/GMT-5",
"Etc/GMT-6",
"Etc/GMT-7",
"Etc/GMT-8",
"Etc/GMT-9",
"Etc/GMT-10",
"Etc/GMT-11",
"Etc/GMT-12",
"Etc/GMT-13",
"Etc/GMT-14",
"UTC",
];
const supportedTimeZones = Intl.supportedValuesOf("timeZone");
for (const tz of nonContinentalTimeZones) {
assert(
supportedTimeZones.includes(tz),
`non-continental timezone ${tz} is not supported`,
);
}