mirror of
https://github.com/tc39/test262.git
synced 2025-11-17 12:19:49 +01:00
Previously, "nested" time zone property bags were unwrapped up to one
level. That is, this object:
{
timeZone: {
// ...Temporal.TimeZone methods
}
}
would not be considered to implement the TimeZone protocol, but would have
its timeZone property used instead, if it were passed to an API that
required a TimeZone protocol object.
These nested property bags are no longer supported. Discussion:
https://github.com/tc39/proposal-temporal/issues/2104#issuecomment-1409549753
Corresponding normative PR:
https://github.com/tc39/proposal-temporal/pull/2485
37 lines
952 B
JavaScript
37 lines
952 B
JavaScript
// Copyright (C) 2020 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: An object is returned unchanged
|
|
features: [Temporal]
|
|
---*/
|
|
|
|
class CustomTimeZone extends Temporal.TimeZone {}
|
|
|
|
const objects = [
|
|
new Temporal.TimeZone("Europe/Madrid"),
|
|
new CustomTimeZone("Africa/Accra"),
|
|
];
|
|
|
|
const thisValues = [
|
|
Temporal.TimeZone,
|
|
CustomTimeZone,
|
|
{},
|
|
null,
|
|
undefined,
|
|
7,
|
|
];
|
|
|
|
for (const thisValue of thisValues) {
|
|
for (const object of objects) {
|
|
const result = Temporal.TimeZone.from.call(thisValue, object);
|
|
assert.sameValue(result, object);
|
|
}
|
|
|
|
const zdt = new Temporal.ZonedDateTime(0n, "Africa/Cairo");
|
|
const fromZdt = Temporal.TimeZone.from.call(thisValue, zdt);
|
|
assert.notSameValue(fromZdt, zdt.getTimeZone(), "from() creates a new object for a string slot value");
|
|
assert.sameValue(fromZdt.id, "Africa/Cairo");
|
|
}
|