mirror of https://github.com/tc39/test262.git
Replace Temporal.Now.timeZone → Temporal.Now.timeZoneId
Now.timeZoneId() returns a string so that it can be used to construct objects that have the builtin time zone behaviour. Normative PR: https://github.com/tc39/proposal-temporal/pull/2482
This commit is contained in:
parent
beb4f26eb4
commit
27d7cdad4e
|
@ -1,13 +0,0 @@
|
||||||
// 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.now.timezone
|
|
||||||
description: Each invocation of the function produces a distinct object value
|
|
||||||
features: [Temporal]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
const tz = Temporal.Now.timeZone;
|
|
||||||
const tz1 = tz();
|
|
||||||
const tz2 = tz();
|
|
||||||
assert.notSameValue(tz1, tz2, 'The value of tz1 is expected to not equal the value of `tz2`');
|
|
|
@ -1,16 +0,0 @@
|
||||||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-temporal.now.timezone
|
|
||||||
description: Temporal.Now.timeZone returns an instance of the TimeZone constructor
|
|
||||||
info: |
|
|
||||||
1. Return ? SystemTimeZone().
|
|
||||||
features: [Temporal]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
assert.sameValue(
|
|
||||||
Object.getPrototypeOf(Temporal.Now.timeZone()),
|
|
||||||
Temporal.TimeZone.prototype,
|
|
||||||
'Object.getPrototypeOf(Temporal.Now.timeZone()) returns Temporal.TimeZone.prototype'
|
|
||||||
);
|
|
|
@ -2,8 +2,8 @@
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-temporal.now.timezone
|
esid: sec-temporal.now.timezoneid
|
||||||
description: Temporal.Now.timeZone is extensible.
|
description: Temporal.Now.timeZoneId is extensible.
|
||||||
info: |
|
info: |
|
||||||
## 17 ECMAScript Standard Built-in Objects
|
## 17 ECMAScript Standard Built-in Objects
|
||||||
|
|
||||||
|
@ -13,6 +13,6 @@ features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
assert(
|
assert(
|
||||||
Object.isExtensible(Temporal.Now.timeZone),
|
Object.isExtensible(Temporal.Now.timeZoneId),
|
||||||
'Object.isExtensible(Temporal.Now.timeZone) must return true'
|
'Object.isExtensible(Temporal.Now.timeZoneId) must return true'
|
||||||
);
|
);
|
|
@ -2,8 +2,8 @@
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-temporal.now.timezone
|
esid: sec-temporal.now.timezoneid
|
||||||
description: Temporal.Now.timeZone.length is 0
|
description: Temporal.Now.timeZoneId.length is 0
|
||||||
info: |
|
info: |
|
||||||
Every built-in function object, including constructors, has a "length" property whose value is
|
Every built-in function object, including constructors, has a "length" property whose value is
|
||||||
an integer. Unless otherwise specified, this value is equal to the largest number of named
|
an integer. Unless otherwise specified, this value is equal to the largest number of named
|
||||||
|
@ -17,7 +17,7 @@ includes: [propertyHelper.js]
|
||||||
features: [Temporal]
|
features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
verifyProperty(Temporal.Now.timeZone, "length", {
|
verifyProperty(Temporal.Now.timeZoneId, "length", {
|
||||||
value: 0,
|
value: 0,
|
||||||
writable: false,
|
writable: false,
|
||||||
enumerable: false,
|
enumerable: false,
|
|
@ -2,8 +2,8 @@
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-temporal.now.timezone
|
esid: sec-temporal.now.timezoneid
|
||||||
description: Temporal.Now.timeZone.name is "timeZone".
|
description: Temporal.Now.timeZoneId.name is "timeZoneId".
|
||||||
info: |
|
info: |
|
||||||
## 17 ECMAScript Standard Built-in Objects:
|
## 17 ECMAScript Standard Built-in Objects:
|
||||||
Every built-in Function object, including constructors, that is not
|
Every built-in Function object, including constructors, that is not
|
||||||
|
@ -18,12 +18,12 @@ features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
Temporal.Now.timeZone.name,
|
Temporal.Now.timeZoneId.name,
|
||||||
'timeZone',
|
'timeZoneId',
|
||||||
'The value of Temporal.Now.timeZone.name is expected to be "timeZone"'
|
'The value of Temporal.Now.timeZoneId.name is expected to be "timeZoneId"'
|
||||||
);
|
);
|
||||||
|
|
||||||
verifyProperty(Temporal.Now.timeZone, 'name', {
|
verifyProperty(Temporal.Now.timeZoneId, 'name', {
|
||||||
enumerable: false,
|
enumerable: false,
|
||||||
writable: false,
|
writable: false,
|
||||||
configurable: true
|
configurable: true
|
|
@ -2,8 +2,8 @@
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-temporal.now.timezone
|
esid: sec-temporal.now.timezoneid
|
||||||
description: Temporal.Now.timeZone does not implement [[Construct]]
|
description: Temporal.Now.timeZoneId does not implement [[Construct]]
|
||||||
info: |
|
info: |
|
||||||
ECMAScript Function Objects
|
ECMAScript Function Objects
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@ includes: [isConstructor.js]
|
||||||
features: [Reflect.construct, Temporal, arrow-function]
|
features: [Reflect.construct, Temporal, arrow-function]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
assert.sameValue(isConstructor(Temporal.Now.timeZone), false, 'isConstructor(Temporal.Now.timeZone) must return false');
|
assert.sameValue(isConstructor(Temporal.Now.timeZoneId), false, 'isConstructor(Temporal.Now.timeZoneId) must return false');
|
||||||
|
|
||||||
assert.throws(TypeError, () => {
|
assert.throws(TypeError, () => {
|
||||||
new Temporal.Now.timeZone();
|
new Temporal.Now.timeZoneId();
|
||||||
}, 'new Temporal.Now.timeZone() throws a TypeError exception');
|
}, 'new Temporal.Now.timeZoneId() throws a TypeError exception');
|
|
@ -2,8 +2,8 @@
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-temporal.now.timezone
|
esid: sec-temporal.now.timezoneid
|
||||||
description: The "timeZone" property of Temporal.Now
|
description: The "timeZoneId" property of Temporal.Now
|
||||||
info: |
|
info: |
|
||||||
Section 17: Every other data property described in clauses 18 through 26
|
Section 17: Every other data property described in clauses 18 through 26
|
||||||
and in Annex B.2 has the attributes { [[Writable]]: true,
|
and in Annex B.2 has the attributes { [[Writable]]: true,
|
||||||
|
@ -12,9 +12,9 @@ includes: [propertyHelper.js]
|
||||||
features: [Temporal]
|
features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
assert.sameValue(typeof Temporal.Now.timeZone, "function", "typeof is function");
|
assert.sameValue(typeof Temporal.Now.timeZoneId, "function", "typeof is function");
|
||||||
|
|
||||||
verifyProperty(Temporal.Now, 'timeZone', {
|
verifyProperty(Temporal.Now, 'timeZoneId', {
|
||||||
enumerable: false,
|
enumerable: false,
|
||||||
writable: true,
|
writable: true,
|
||||||
configurable: true
|
configurable: true
|
|
@ -0,0 +1,16 @@
|
||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-temporal.now.timezoneid
|
||||||
|
description: Temporal.Now.timeZoneId returns a string
|
||||||
|
info: |
|
||||||
|
1. Return DefaultTimeZone().
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
typeof Temporal.Now.timeZoneId(),
|
||||||
|
"string",
|
||||||
|
"Temporal.Now.timeZoneId() returns a string"
|
||||||
|
);
|
|
@ -18,14 +18,14 @@ Object.defineProperty(Temporal.TimeZone, "from", {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const systemTimeZone = Temporal.Now.timeZone();
|
const systemTimeZone = Temporal.Now.timeZoneId();
|
||||||
|
|
||||||
const resultExplicit = Temporal.Now.zonedDateTime('iso8601', undefined);
|
const resultExplicit = Temporal.Now.zonedDateTime('iso8601', undefined);
|
||||||
assert.sameValue(resultExplicit.timeZone.id, systemTimeZone.id);
|
assert.sameValue(resultExplicit.timeZone.id, systemTimeZone);
|
||||||
|
|
||||||
assert.compareArray(actual, expected, "Temporal.TimeZone.from should not be called");
|
assert.compareArray(actual, expected, "Temporal.TimeZone.from should not be called");
|
||||||
|
|
||||||
const resultImplicit = Temporal.Now.zonedDateTime('iso8601');
|
const resultImplicit = Temporal.Now.zonedDateTime('iso8601');
|
||||||
assert.sameValue(resultImplicit.timeZone.id, systemTimeZone.id);
|
assert.sameValue(resultImplicit.timeZone.id, systemTimeZone);
|
||||||
|
|
||||||
assert.compareArray(actual, expected, "Temporal.TimeZone.from should not be called");
|
assert.compareArray(actual, expected, "Temporal.TimeZone.from should not be called");
|
||||||
|
|
|
@ -8,9 +8,9 @@ features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
const zdt = Temporal.Now.zonedDateTimeISO();
|
const zdt = Temporal.Now.zonedDateTimeISO();
|
||||||
const tz = Temporal.Now.timeZone();
|
const tz = Temporal.Now.timeZoneId();
|
||||||
assert(zdt instanceof Temporal.ZonedDateTime);
|
assert(zdt instanceof Temporal.ZonedDateTime);
|
||||||
assert(zdt.calendar instanceof Temporal.Calendar);
|
assert(zdt.calendar instanceof Temporal.Calendar);
|
||||||
assert.sameValue(zdt.calendar.id, "iso8601");
|
assert.sameValue(zdt.calendar.id, "iso8601");
|
||||||
assert(zdt.timeZone instanceof Temporal.TimeZone);
|
assert(zdt.timeZone instanceof Temporal.TimeZone);
|
||||||
assert.sameValue(zdt.timeZone.id, tz.id);
|
assert.sameValue(zdt.timeZone.id, tz);
|
||||||
|
|
|
@ -18,14 +18,14 @@ Object.defineProperty(Temporal.TimeZone, "from", {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const systemTimeZone = Temporal.Now.timeZone();
|
const systemTimeZone = Temporal.Now.timeZoneId();
|
||||||
|
|
||||||
const resultExplicit = Temporal.Now.zonedDateTimeISO(undefined);
|
const resultExplicit = Temporal.Now.zonedDateTimeISO(undefined);
|
||||||
assert.sameValue(resultExplicit.timeZone.id, systemTimeZone.id);
|
assert.sameValue(resultExplicit.timeZone.id, systemTimeZone);
|
||||||
|
|
||||||
assert.compareArray(actual, expected, "Temporal.TimeZone.from should not be called");
|
assert.compareArray(actual, expected, "Temporal.TimeZone.from should not be called");
|
||||||
|
|
||||||
const resultImplicit = Temporal.Now.zonedDateTimeISO();
|
const resultImplicit = Temporal.Now.zonedDateTimeISO();
|
||||||
assert.sameValue(resultImplicit.timeZone.id, systemTimeZone.id);
|
assert.sameValue(resultImplicit.timeZone.id, systemTimeZone);
|
||||||
|
|
||||||
assert.compareArray(actual, expected, "Temporal.TimeZone.from should not be called");
|
assert.compareArray(actual, expected, "Temporal.TimeZone.from should not be called");
|
||||||
|
|
|
@ -8,10 +8,10 @@ features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
const zdt = Temporal.Now.zonedDateTime("gregory");
|
const zdt = Temporal.Now.zonedDateTime("gregory");
|
||||||
const tz = Temporal.Now.timeZone();
|
const tz = Temporal.Now.timeZoneId();
|
||||||
assert(zdt instanceof Temporal.ZonedDateTime);
|
assert(zdt instanceof Temporal.ZonedDateTime);
|
||||||
assert(zdt.calendar instanceof Temporal.Calendar);
|
assert(zdt.calendar instanceof Temporal.Calendar);
|
||||||
assert.sameValue(zdt.calendar.id, "gregory");
|
assert.sameValue(zdt.calendar.id, "gregory");
|
||||||
assert(zdt.timeZone instanceof Temporal.TimeZone);
|
assert(zdt.timeZone instanceof Temporal.TimeZone);
|
||||||
assert.sameValue(zdt.timeZone.id, tz.id);
|
assert.sameValue(zdt.timeZone.id, tz);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue