test262/test/built-ins/Temporal/TimeZone/from/timezone-string.js

35 lines
1.4 KiB
JavaScript

// 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.from
description: Time zone IDs are valid input for a time zone
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
["UTC", "+01:30"].forEach((timeZone) => {
const result = Temporal.TimeZone.from(timeZone);
assert.sameValue(result.id, timeZone, `Time zone created from string "${timeZone}"`);
});
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);