Skip to content

Commit

Permalink
Replace Temporal.Now.timeZone → Temporal.Now.timeZoneId
Browse files Browse the repository at this point in the history
Now.timeZoneId() returns a string so that it can be used to construct
objects that have the builtin time zone behaviour.

Normative PR: tc39/proposal-temporal#2482
  • Loading branch information
ptomato committed Feb 18, 2023
1 parent 76a14bf commit d4a5ee8
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 61 deletions.
13 changes: 0 additions & 13 deletions test/built-ins/Temporal/Now/timeZone/new-object.js

This file was deleted.

16 changes: 0 additions & 16 deletions test/built-ins/Temporal/Now/timeZone/return-value.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.now.timezone
description: Temporal.Now.timeZone is extensible.
esid: sec-temporal.now.timezoneid
description: Temporal.Now.timeZoneId is extensible.
info: |
## 17 ECMAScript Standard Built-in Objects
Expand All @@ -13,6 +13,6 @@ features: [Temporal]
---*/

assert(
Object.isExtensible(Temporal.Now.timeZone),
'Object.isExtensible(Temporal.Now.timeZone) must return true'
Object.isExtensible(Temporal.Now.timeZoneId),
'Object.isExtensible(Temporal.Now.timeZoneId) must return true'
);
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.now.timezone
description: Temporal.Now.timeZone.length is 0
esid: sec-temporal.now.timezoneid
description: Temporal.Now.timeZoneId.length is 0
info: |
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
Expand All @@ -17,7 +17,7 @@ includes: [propertyHelper.js]
features: [Temporal]
---*/

verifyProperty(Temporal.Now.timeZone, "length", {
verifyProperty(Temporal.Now.timeZoneId, "length", {
value: 0,
writable: false,
enumerable: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.now.timezone
description: Temporal.Now.timeZone.name is "timeZone".
esid: sec-temporal.now.timezoneid
description: Temporal.Now.timeZoneId.name is "timeZoneId".
info: |
## 17 ECMAScript Standard Built-in Objects:
Every built-in Function object, including constructors, that is not
Expand All @@ -18,12 +18,12 @@ features: [Temporal]
---*/

assert.sameValue(
Temporal.Now.timeZone.name,
'timeZone',
'The value of Temporal.Now.timeZone.name is expected to be "timeZone"'
Temporal.Now.timeZoneId.name,
'timeZoneId',
'The value of Temporal.Now.timeZoneId.name is expected to be "timeZoneId"'
);

verifyProperty(Temporal.Now.timeZone, 'name', {
verifyProperty(Temporal.Now.timeZoneId, 'name', {
enumerable: false,
writable: false,
configurable: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.now.timezone
description: Temporal.Now.timeZone does not implement [[Construct]]
esid: sec-temporal.now.timezoneid
description: Temporal.Now.timeZoneId does not implement [[Construct]]
info: |
ECMAScript Function Objects
Expand All @@ -14,8 +14,8 @@ includes: [isConstructor.js]
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, () => {
new Temporal.Now.timeZone();
}, 'new Temporal.Now.timeZone() throws a TypeError exception');
new Temporal.Now.timeZoneId();
}, 'new Temporal.Now.timeZoneId() throws a TypeError exception');
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.now.timezone
description: The "timeZone" property of Temporal.Now
esid: sec-temporal.now.timezoneid
description: The "timeZoneId" property of Temporal.Now
info: |
Section 17: Every other data property described in clauses 18 through 26
and in Annex B.2 has the attributes { [[Writable]]: true,
Expand All @@ -12,9 +12,9 @@ includes: [propertyHelper.js]
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,
writable: true,
configurable: true
Expand Down
16 changes: 16 additions & 0 deletions test/built-ins/Temporal/Now/timeZoneId/return-value.js
Original file line number Diff line number Diff line change
@@ -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"
);
Original file line number Diff line number Diff line change
Expand Up @@ -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);
assert.sameValue(resultExplicit.timeZone.id, systemTimeZone.id);
assert.sameValue(resultExplicit.timeZone.id, systemTimeZone);

assert.compareArray(actual, expected, "Temporal.TimeZone.from should not be called");

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");
4 changes: 2 additions & 2 deletions test/built-ins/Temporal/Now/zonedDateTimeISO/return-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ features: [Temporal]
---*/

const zdt = Temporal.Now.zonedDateTimeISO();
const tz = Temporal.Now.timeZone();
const tz = Temporal.Now.timeZoneId();
assert(zdt instanceof Temporal.ZonedDateTime);
assert(zdt.calendar instanceof Temporal.Calendar);
assert.sameValue(zdt.calendar.id, "iso8601");
assert(zdt.timeZone instanceof Temporal.TimeZone);
assert.sameValue(zdt.timeZone.id, tz.id);
assert.sameValue(zdt.timeZone.id, tz);
Original file line number Diff line number Diff line change
Expand Up @@ -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);
assert.sameValue(resultExplicit.timeZone.id, systemTimeZone.id);
assert.sameValue(resultExplicit.timeZone.id, systemTimeZone);

assert.compareArray(actual, expected, "Temporal.TimeZone.from should not be called");

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");
4 changes: 2 additions & 2 deletions test/intl402/Temporal/Now/zonedDateTime/calendar-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ features: [Temporal]
---*/

const zdt = Temporal.Now.zonedDateTime("gregory");
const tz = Temporal.Now.timeZone();
const tz = Temporal.Now.timeZoneId();
assert(zdt instanceof Temporal.ZonedDateTime);
assert(zdt.calendar instanceof Temporal.Calendar);
assert.sameValue(zdt.calendar.id, "gregory");
assert(zdt.timeZone instanceof Temporal.TimeZone);
assert.sameValue(zdt.timeZone.id, tz.id);
assert.sameValue(zdt.timeZone.id, tz);

0 comments on commit d4a5ee8

Please sign in to comment.