Philip Chimento f2871840b8 Replace Temporal.ZonedDateTime.timeZone getter with new API
This is the replacement of the old API with the new API, .timeZoneId and
.getTimeZone(). Semantics will be corrected in the following commit.

Normative PR: https://github.com/tc39/proposal-temporal/pull/2482
2023-04-07 11:43:31 -07:00

32 lines
1.0 KiB
JavaScript

// Copyright (C) 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.now.zoneddatetimeiso
description: Functions when time zone argument is omitted
includes: [compareArray.js]
features: [Temporal]
---*/
const actual = [];
const expected = [];
Object.defineProperty(Temporal.TimeZone, "from", {
get() {
actual.push("get Temporal.TimeZone.from");
return undefined;
},
});
const systemTimeZone = Temporal.Now.timeZoneId();
const resultExplicit = Temporal.Now.zonedDateTimeISO(undefined);
assert.sameValue(resultExplicit.getISOFields().timeZone, systemTimeZone, "time zone slot should store a string");
assert.compareArray(actual, expected, "Temporal.TimeZone.from should not be called");
const resultImplicit = Temporal.Now.zonedDateTimeISO();
assert.sameValue(resultImplicit.getISOFields().timeZone, systemTimeZone, "time zone slot should store a string");
assert.compareArray(actual, expected, "Temporal.TimeZone.from should not be called");