Temporal: Add tests for IANA legacy name time zones

Aside from the ones that were already tested in etc-timezones.js, this
adds a test for other IANA legacy names.

Previously these were supported in the TimeZone constructor, but not in
from().

See https://github.com/tc39/proposal-temporal/pull/2292 which is a
normative change that achieved consensus at the July 2022 TC39 meeting.
This commit is contained in:
Philip Chimento 2022-07-26 11:12:45 -07:00 committed by Philip Chimento
parent 5cb596f191
commit 8ea8e3f15d
2 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,24 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.timezone
description: IANA legacy names must be supported
features: [Temporal]
---*/
const legacyNames = [
["Etc/GMT0", "UTC"],
["GMT0", "UTC"],
["GMT-0", "UTC"],
["GMT+0", "UTC"],
["EST5EDT", "EST5EDT"],
["CST6CDT", "CST6CDT"],
["MST7MDT", "MST7MDT"],
["PST8PDT", "PST8PDT"],
];
legacyNames.forEach(([arg, expectedID]) => {
const tz = Temporal.TimeZone.from(arg);
assert.sameValue(tz.toString(), expectedID, `"${arg}" is a supported name for the "${expectedID}" time zone`);
});

View File

@ -0,0 +1,24 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.timezone
description: IANA legacy names must be supported
features: [Temporal]
---*/
const legacyNames = [
["Etc/GMT0", "UTC"],
["GMT0", "UTC"],
["GMT-0", "UTC"],
["GMT+0", "UTC"],
["EST5EDT", "EST5EDT"],
["CST6CDT", "CST6CDT"],
["MST7MDT", "MST7MDT"],
["PST8PDT", "PST8PDT"],
];
legacyNames.forEach(([arg, expectedID]) => {
const tz = new Temporal.TimeZone(arg);
assert.sameValue(tz.toString(), expectedID, `"${arg}" is a supported name for the "${expectedID}" time zone`);
});