mirror of
https://github.com/tc39/test262.git
synced 2025-04-08 19:35:28 +02:00
Temporal: Remove epoch seconds and epoch microseconds APIs
See: tc39/proposal-temporal#2849
This commit is contained in:
parent
7184313667
commit
1c900ca59c
@ -9,12 +9,10 @@ features: [Temporal]
|
||||
|
||||
const bigIntInstant = new Temporal.Instant(217175010123456789n);
|
||||
assert(bigIntInstant instanceof Temporal.Instant, "BigInt instanceof");
|
||||
assert.sameValue(bigIntInstant.epochSeconds, 217175010, "BigInt epochSeconds");
|
||||
assert.sameValue(bigIntInstant.epochMilliseconds, 217175010123, "BigInt epochMilliseconds");
|
||||
|
||||
const stringInstant = new Temporal.Instant("217175010123456789");
|
||||
assert(stringInstant instanceof Temporal.Instant, "String instanceof");
|
||||
assert.sameValue(stringInstant.epochSeconds, 217175010, "String epochSeconds");
|
||||
assert.sameValue(stringInstant.epochMilliseconds, 217175010123, "String epochMilliseconds");
|
||||
|
||||
assert.throws(SyntaxError, () => new Temporal.Instant("abc123"), "invalid BigInt syntax");
|
||||
|
@ -1,14 +0,0 @@
|
||||
// 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.instant.fromepochmicroseconds
|
||||
description: Basic tests for Instant.fromEpochMicroseconds().
|
||||
features: [BigInt, Temporal]
|
||||
---*/
|
||||
|
||||
const afterEpoch = Temporal.Instant.fromEpochMicroseconds(217175010_123_456n);
|
||||
assert.sameValue(afterEpoch.epochNanoseconds, 217175010_123_456_000n, "fromEpochMicroseconds post epoch");
|
||||
|
||||
const beforeEpoch = Temporal.Instant.fromEpochMicroseconds(-217175010_876_543n);
|
||||
assert.sameValue(beforeEpoch.epochNanoseconds, -217175010_876_543_000n, "fromEpochMicroseconds pre epoch");
|
@ -1,30 +0,0 @@
|
||||
// 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.instant.fromepochmicroseconds
|
||||
description: Tests that Temporal.Instant.fromEpochMicroseconds meets the requirements for built-in objects
|
||||
info: |
|
||||
Built-in functions that are not constructors do not have a "prototype" property unless
|
||||
otherwise specified in the description of a particular function.
|
||||
|
||||
Unless specified otherwise, a built-in object that is callable as a function is a built-in
|
||||
function object with the characteristics described in 10.3. Unless specified otherwise, the
|
||||
[[Extensible]] internal slot of a built-in object initially has the value true.
|
||||
|
||||
Unless otherwise specified every built-in function and every built-in constructor has the
|
||||
Function prototype object [...] as the value of its [[Prototype]] internal slot.
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Object.isExtensible(Temporal.Instant.fromEpochMicroseconds),
|
||||
true, "Built-in objects must be extensible.");
|
||||
|
||||
assert.sameValue(Object.prototype.toString.call(Temporal.Instant.fromEpochMicroseconds),
|
||||
"[object Function]", "Object.prototype.toString");
|
||||
|
||||
assert.sameValue(Object.getPrototypeOf(Temporal.Instant.fromEpochMicroseconds),
|
||||
Function.prototype, "prototype");
|
||||
|
||||
assert.sameValue(Temporal.Instant.fromEpochMicroseconds.hasOwnProperty("prototype"),
|
||||
false, "prototype property");
|
@ -1,25 +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.instant.fromepochmicroseconds
|
||||
description: Temporal.Instant.fromEpochMicroseconds.length is 1
|
||||
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
|
||||
arguments shown in the subclause headings for the function description. Optional parameters
|
||||
(which are indicated with brackets: [ ]) or rest parameters (which are shown using the form
|
||||
«...name») are not included in the default argument count.
|
||||
|
||||
Unless otherwise specified, the "length" property of a built-in function object has the
|
||||
attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
|
||||
includes: [propertyHelper.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
verifyProperty(Temporal.Instant.fromEpochMicroseconds, "length", {
|
||||
value: 1,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
@ -1,23 +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.instant.fromepochmicroseconds
|
||||
description: Temporal.Instant.fromEpochMicroseconds.name is "fromEpochMicroseconds"
|
||||
info: |
|
||||
Every built-in function object, including constructors, that is not identified as an anonymous
|
||||
function has a "name" property whose value is a String. Unless otherwise specified, this value
|
||||
is the name that is given to the function in this specification.
|
||||
|
||||
Unless otherwise specified, the "name" property of a built-in function object, if it exists,
|
||||
has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
|
||||
includes: [propertyHelper.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
verifyProperty(Temporal.Instant.fromEpochMicroseconds, "name", {
|
||||
value: "fromEpochMicroseconds",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
@ -1,20 +0,0 @@
|
||||
// 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.instant.fromepochmicroseconds
|
||||
description: Temporal.Instant.fromEpochMicroseconds does not implement [[Construct]], is not new-able
|
||||
info: |
|
||||
Built-in function objects that are not identified as constructors do not implement the
|
||||
[[Construct]] internal method unless otherwise specified in the description of a particular
|
||||
function.
|
||||
includes: [isConstructor.js]
|
||||
features: [Reflect.construct, Temporal]
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, () => {
|
||||
new Temporal.Instant.fromEpochMicroseconds();
|
||||
}, "Calling as constructor");
|
||||
|
||||
assert.sameValue(isConstructor(Temporal.Instant.fromEpochMicroseconds), false,
|
||||
"isConstructor(Temporal.Instant.fromEpochMicroseconds)");
|
@ -1,21 +0,0 @@
|
||||
// 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.instant.fromepochmicroseconds
|
||||
description: The "fromEpochMicroseconds" property of Temporal.Instant
|
||||
includes: [propertyHelper.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof Temporal.Instant.fromEpochMicroseconds,
|
||||
"function",
|
||||
"`typeof Instant.fromEpochMicroseconds` is `function`"
|
||||
);
|
||||
|
||||
verifyProperty(Temporal.Instant, "fromEpochMicroseconds", {
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
@ -1,18 +0,0 @@
|
||||
// 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.instant.fromepochmicroseconds
|
||||
description: The receiver is never called by fromEpochMicroseconds()
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
TemporalHelpers.checkSubclassingIgnoredStatic(
|
||||
Temporal.Instant,
|
||||
"fromEpochMicroseconds",
|
||||
[10n],
|
||||
(result) => {
|
||||
assert.sameValue(result.epochNanoseconds, 10_000n, "epochNanoseconds result");
|
||||
},
|
||||
);
|
@ -1,14 +0,0 @@
|
||||
// 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.instant.fromepochseconds
|
||||
description: Basic tests for Instant.fromEpochSeconds().
|
||||
features: [BigInt, Temporal]
|
||||
---*/
|
||||
|
||||
const afterEpoch = Temporal.Instant.fromEpochSeconds(217175010);
|
||||
assert.sameValue(afterEpoch.epochNanoseconds, 217175010_000_000_000n, "fromEpochSeconds post epoch");
|
||||
|
||||
const beforeEpoch = Temporal.Instant.fromEpochSeconds(-217175010);
|
||||
assert.sameValue(beforeEpoch.epochNanoseconds, -217175010_000_000_000n, "fromEpochSeconds pre epoch");
|
@ -1,30 +0,0 @@
|
||||
// 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.instant.fromepochseconds
|
||||
description: Tests that Temporal.Instant.fromEpochSeconds meets the requirements for built-in objects
|
||||
info: |
|
||||
Built-in functions that are not constructors do not have a "prototype" property unless
|
||||
otherwise specified in the description of a particular function.
|
||||
|
||||
Unless specified otherwise, a built-in object that is callable as a function is a built-in
|
||||
function object with the characteristics described in 10.3. Unless specified otherwise, the
|
||||
[[Extensible]] internal slot of a built-in object initially has the value true.
|
||||
|
||||
Unless otherwise specified every built-in function and every built-in constructor has the
|
||||
Function prototype object [...] as the value of its [[Prototype]] internal slot.
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Object.isExtensible(Temporal.Instant.fromEpochSeconds),
|
||||
true, "Built-in objects must be extensible.");
|
||||
|
||||
assert.sameValue(Object.prototype.toString.call(Temporal.Instant.fromEpochSeconds),
|
||||
"[object Function]", "Object.prototype.toString");
|
||||
|
||||
assert.sameValue(Object.getPrototypeOf(Temporal.Instant.fromEpochSeconds),
|
||||
Function.prototype, "prototype");
|
||||
|
||||
assert.sameValue(Temporal.Instant.fromEpochSeconds.hasOwnProperty("prototype"),
|
||||
false, "prototype property");
|
@ -1,25 +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.instant.fromepochseconds
|
||||
description: Temporal.Instant.fromEpochSeconds.length is 1
|
||||
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
|
||||
arguments shown in the subclause headings for the function description. Optional parameters
|
||||
(which are indicated with brackets: [ ]) or rest parameters (which are shown using the form
|
||||
«...name») are not included in the default argument count.
|
||||
|
||||
Unless otherwise specified, the "length" property of a built-in function object has the
|
||||
attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
|
||||
includes: [propertyHelper.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
verifyProperty(Temporal.Instant.fromEpochSeconds, "length", {
|
||||
value: 1,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
@ -1,23 +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.instant.fromepochseconds
|
||||
description: Temporal.Instant.fromEpochSeconds.name is "fromEpochSeconds"
|
||||
info: |
|
||||
Every built-in function object, including constructors, that is not identified as an anonymous
|
||||
function has a "name" property whose value is a String. Unless otherwise specified, this value
|
||||
is the name that is given to the function in this specification.
|
||||
|
||||
Unless otherwise specified, the "name" property of a built-in function object, if it exists,
|
||||
has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
|
||||
includes: [propertyHelper.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
verifyProperty(Temporal.Instant.fromEpochSeconds, "name", {
|
||||
value: "fromEpochSeconds",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
@ -1,20 +0,0 @@
|
||||
// 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.instant.fromepochseconds
|
||||
description: Temporal.Instant.fromEpochSeconds does not implement [[Construct]], is not new-able
|
||||
info: |
|
||||
Built-in function objects that are not identified as constructors do not implement the
|
||||
[[Construct]] internal method unless otherwise specified in the description of a particular
|
||||
function.
|
||||
includes: [isConstructor.js]
|
||||
features: [Reflect.construct, Temporal]
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, () => {
|
||||
new Temporal.Instant.fromEpochSeconds();
|
||||
}, "Calling as constructor");
|
||||
|
||||
assert.sameValue(isConstructor(Temporal.Instant.fromEpochSeconds), false,
|
||||
"isConstructor(Temporal.Instant.fromEpochSeconds)");
|
@ -1,21 +0,0 @@
|
||||
// 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.instant.fromepochseconds
|
||||
description: The "fromEpochSeconds" property of Temporal.Instant
|
||||
includes: [propertyHelper.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof Temporal.Instant.fromEpochSeconds,
|
||||
"function",
|
||||
"`typeof Instant.fromEpochSeconds` is `function`"
|
||||
);
|
||||
|
||||
verifyProperty(Temporal.Instant, "fromEpochSeconds", {
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
@ -1,18 +0,0 @@
|
||||
// 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.instant.fromepochseconds
|
||||
description: The receiver is never called by fromEpochSeconds()
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
TemporalHelpers.checkSubclassingIgnoredStatic(
|
||||
Temporal.Instant,
|
||||
"fromEpochSeconds",
|
||||
[10],
|
||||
(result) => {
|
||||
assert.sameValue(result.epochNanoseconds, 10_000_000_000n, "epochNanoseconds result");
|
||||
},
|
||||
);
|
@ -7,6 +7,6 @@ description: A string is parsed into the correct object when passed as the argum
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = Temporal.Instant.fromEpochSeconds(10);
|
||||
const instance = Temporal.Instant.fromEpochMilliseconds(10_000);
|
||||
const result = instance.add("PT3H");
|
||||
assert.sameValue(result.epochNanoseconds, 10_810_000_000_000n, "epochNanoseconds result");
|
||||
|
@ -9,7 +9,7 @@ features: [Temporal]
|
||||
|
||||
const fields = ["hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds"];
|
||||
|
||||
const instance = Temporal.Instant.fromEpochSeconds(10);
|
||||
const instance = Temporal.Instant.fromEpochMilliseconds(10_000);
|
||||
|
||||
fields.forEach((field) => {
|
||||
assert.throws(RangeError, () => instance.add({ [field]: Infinity }));
|
||||
|
@ -9,7 +9,7 @@ features: [Temporal]
|
||||
|
||||
const fields = ["hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds"];
|
||||
|
||||
const instance = Temporal.Instant.fromEpochSeconds(10);
|
||||
const instance = Temporal.Instant.fromEpochMilliseconds(10_000);
|
||||
|
||||
fields.forEach((field) => {
|
||||
assert.throws(RangeError, () => instance.add({ [field]: -Infinity }));
|
||||
|
@ -1,16 +0,0 @@
|
||||
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-get-temporal.instant.prototype.epochmicroseconds
|
||||
description: Basic tests for epochMicroseconds.
|
||||
features: [BigInt, Temporal]
|
||||
---*/
|
||||
|
||||
const afterEpoch = new Temporal.Instant(217175010_123_456_789n);
|
||||
assert.sameValue(afterEpoch.epochMicroseconds, 217175010_123_456n, "epochMicroseconds post epoch");
|
||||
assert.sameValue(typeof afterEpoch.epochMicroseconds, "bigint", "epochMicroseconds value is a bigint");
|
||||
|
||||
const beforeEpoch = new Temporal.Instant(-217175010_876_543_211n);
|
||||
assert.sameValue(beforeEpoch.epochMicroseconds, -217175010_876_544n, "epochMicroseconds pre epoch");
|
||||
assert.sameValue(typeof beforeEpoch.epochMicroseconds, "bigint", "epochMicroseconds value is a bigint");
|
@ -1,22 +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-get-temporal.instant.prototype.epochmicroseconds
|
||||
description: Throw a TypeError if the receiver is invalid
|
||||
features: [Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const epochMicroseconds = Object.getOwnPropertyDescriptor(Temporal.Instant.prototype, "epochMicroseconds").get;
|
||||
|
||||
assert.sameValue(typeof epochMicroseconds, "function");
|
||||
|
||||
assert.throws(TypeError, () => epochMicroseconds.call(undefined), "undefined");
|
||||
assert.throws(TypeError, () => epochMicroseconds.call(null), "null");
|
||||
assert.throws(TypeError, () => epochMicroseconds.call(true), "true");
|
||||
assert.throws(TypeError, () => epochMicroseconds.call(""), "empty string");
|
||||
assert.throws(TypeError, () => epochMicroseconds.call(Symbol()), "symbol");
|
||||
assert.throws(TypeError, () => epochMicroseconds.call(1), "1");
|
||||
assert.throws(TypeError, () => epochMicroseconds.call({}), "plain object");
|
||||
assert.throws(TypeError, () => epochMicroseconds.call(Temporal.Instant), "Temporal.Instant");
|
||||
assert.throws(TypeError, () => epochMicroseconds.call(Temporal.Instant.prototype), "Temporal.Instant.prototype");
|
@ -1,14 +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-get-temporal.instant.prototype.epochmicroseconds
|
||||
description: The "epochMicroseconds" property of Temporal.Instant.prototype
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const descriptor = Object.getOwnPropertyDescriptor(Temporal.Instant.prototype, "epochMicroseconds");
|
||||
assert.sameValue(typeof descriptor.get, "function");
|
||||
assert.sameValue(descriptor.set, undefined);
|
||||
assert.sameValue(descriptor.enumerable, false);
|
||||
assert.sameValue(descriptor.configurable, true);
|
@ -1,16 +0,0 @@
|
||||
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-get-temporal.instant.prototype.epochseconds
|
||||
description: Basic tests for epochSeconds.
|
||||
features: [BigInt, Temporal]
|
||||
---*/
|
||||
|
||||
const afterEpoch = new Temporal.Instant(217175010_123_456_789n);
|
||||
assert.sameValue(afterEpoch.epochSeconds, 217175010, "epochSeconds post epoch");
|
||||
assert.sameValue(typeof afterEpoch.epochSeconds, "number", "epochSeconds value is a number");
|
||||
|
||||
const beforeEpoch = new Temporal.Instant(-217175010_876_543_211n);
|
||||
assert.sameValue(beforeEpoch.epochSeconds, -217175011, "epochSeconds pre epoch");
|
||||
assert.sameValue(typeof beforeEpoch.epochSeconds, "number", "epochSeconds value is a number");
|
@ -1,22 +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-get-temporal.instant.prototype.epochseconds
|
||||
description: Throw a TypeError if the receiver is invalid
|
||||
features: [Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const epochSeconds = Object.getOwnPropertyDescriptor(Temporal.Instant.prototype, "epochSeconds").get;
|
||||
|
||||
assert.sameValue(typeof epochSeconds, "function");
|
||||
|
||||
assert.throws(TypeError, () => epochSeconds.call(undefined), "undefined");
|
||||
assert.throws(TypeError, () => epochSeconds.call(null), "null");
|
||||
assert.throws(TypeError, () => epochSeconds.call(true), "true");
|
||||
assert.throws(TypeError, () => epochSeconds.call(""), "empty string");
|
||||
assert.throws(TypeError, () => epochSeconds.call(Symbol()), "symbol");
|
||||
assert.throws(TypeError, () => epochSeconds.call(1), "1");
|
||||
assert.throws(TypeError, () => epochSeconds.call({}), "plain object");
|
||||
assert.throws(TypeError, () => epochSeconds.call(Temporal.Instant), "Temporal.Instant");
|
||||
assert.throws(TypeError, () => epochSeconds.call(Temporal.Instant.prototype), "Temporal.Instant.prototype");
|
@ -1,14 +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-get-temporal.instant.prototype.epochseconds
|
||||
description: The "epochSeconds" property of Temporal.Instant.prototype
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const descriptor = Object.getOwnPropertyDescriptor(Temporal.Instant.prototype, "epochSeconds");
|
||||
assert.sameValue(typeof descriptor.get, "function");
|
||||
assert.sameValue(descriptor.set, undefined);
|
||||
assert.sameValue(descriptor.enumerable, false);
|
||||
assert.sameValue(descriptor.configurable, true);
|
@ -7,6 +7,6 @@ description: A string is parsed into the correct object when passed as the argum
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = Temporal.Instant.fromEpochSeconds(10);
|
||||
const instance = Temporal.Instant.fromEpochMilliseconds(10_000);
|
||||
const result = instance.subtract("PT3H");
|
||||
assert.sameValue(result.epochNanoseconds, -10_790_000_000_000n, "epochNanoseconds result");
|
||||
|
@ -9,7 +9,7 @@ features: [Temporal]
|
||||
|
||||
const fields = ["hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds"];
|
||||
|
||||
const instance = Temporal.Instant.fromEpochSeconds(10);
|
||||
const instance = Temporal.Instant.fromEpochMilliseconds(10_000);
|
||||
|
||||
fields.forEach((field) => {
|
||||
assert.throws(RangeError, () => instance.subtract({ [field]: Infinity }));
|
||||
|
@ -9,7 +9,7 @@ features: [Temporal]
|
||||
|
||||
const fields = ["hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds"];
|
||||
|
||||
const instance = Temporal.Instant.fromEpochSeconds(10);
|
||||
const instance = Temporal.Instant.fromEpochMilliseconds(10_000);
|
||||
|
||||
fields.forEach((field) => {
|
||||
assert.throws(RangeError, () => instance.subtract({ [field]: -Infinity }));
|
||||
|
@ -1,16 +0,0 @@
|
||||
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-get-temporal.zoneddatetime.prototype.epochmicroseconds
|
||||
description: Basic tests for epochMicroseconds.
|
||||
features: [BigInt, Temporal]
|
||||
---*/
|
||||
|
||||
const afterEpoch = new Temporal.ZonedDateTime(217175010_123_456_789n, "UTC");
|
||||
assert.sameValue(afterEpoch.epochMicroseconds, 217175010_123_456n, "epochMicroseconds post epoch");
|
||||
assert.sameValue(typeof afterEpoch.epochMicroseconds, "bigint", "epochMicroseconds value is a bigint");
|
||||
|
||||
const beforeEpoch = new Temporal.ZonedDateTime(-217175010_876_543_211n, "UTC");
|
||||
assert.sameValue(beforeEpoch.epochMicroseconds, -217175010_876_544n, "epochMicroseconds pre epoch");
|
||||
assert.sameValue(typeof beforeEpoch.epochMicroseconds, "bigint", "epochMicroseconds value is a bigint");
|
@ -1,22 +0,0 @@
|
||||
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-get-temporal.zoneddatetime.prototype.epochmicroseconds
|
||||
description: Throw a TypeError if the receiver is invalid
|
||||
features: [Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const epochMicroseconds = Object.getOwnPropertyDescriptor(Temporal.ZonedDateTime.prototype, "epochMicroseconds").get;
|
||||
|
||||
assert.sameValue(typeof epochMicroseconds, "function");
|
||||
|
||||
assert.throws(TypeError, () => epochMicroseconds.call(undefined), "undefined");
|
||||
assert.throws(TypeError, () => epochMicroseconds.call(null), "null");
|
||||
assert.throws(TypeError, () => epochMicroseconds.call(true), "true");
|
||||
assert.throws(TypeError, () => epochMicroseconds.call(""), "empty string");
|
||||
assert.throws(TypeError, () => epochMicroseconds.call(Symbol()), "symbol");
|
||||
assert.throws(TypeError, () => epochMicroseconds.call(1), "1");
|
||||
assert.throws(TypeError, () => epochMicroseconds.call({}), "plain object");
|
||||
assert.throws(TypeError, () => epochMicroseconds.call(Temporal.ZonedDateTime), "Temporal.ZonedDateTime");
|
||||
assert.throws(TypeError, () => epochMicroseconds.call(Temporal.ZonedDateTime.prototype), "Temporal.ZonedDateTime.prototype");
|
@ -1,14 +0,0 @@
|
||||
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-get-temporal.zoneddatetime.prototype.epochmicroseconds
|
||||
description: The "epochMicroseconds" property of Temporal.ZonedDateTime.prototype
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const descriptor = Object.getOwnPropertyDescriptor(Temporal.ZonedDateTime.prototype, "epochMicroseconds");
|
||||
assert.sameValue(typeof descriptor.get, "function");
|
||||
assert.sameValue(descriptor.set, undefined);
|
||||
assert.sameValue(descriptor.enumerable, false);
|
||||
assert.sameValue(descriptor.configurable, true);
|
@ -1,16 +0,0 @@
|
||||
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-get-temporal.zoneddatetime.prototype.epochseconds
|
||||
description: Basic tests for epochSeconds.
|
||||
features: [BigInt, Temporal]
|
||||
---*/
|
||||
|
||||
const afterEpoch = new Temporal.ZonedDateTime(217175010_123_456_789n, "UTC");
|
||||
assert.sameValue(afterEpoch.epochSeconds, 217175010, "epochSeconds post epoch");
|
||||
assert.sameValue(typeof afterEpoch.epochSeconds, "number", "epochSeconds value is a number");
|
||||
|
||||
const beforeEpoch = new Temporal.ZonedDateTime(-217175010_876_543_211n, "UTC");
|
||||
assert.sameValue(beforeEpoch.epochSeconds, -217175011, "epochSeconds pre epoch");
|
||||
assert.sameValue(typeof beforeEpoch.epochSeconds, "number", "epochSeconds value is a number");
|
@ -1,22 +0,0 @@
|
||||
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-get-temporal.zoneddatetime.prototype.epochseconds
|
||||
description: Throw a TypeError if the receiver is invalid
|
||||
features: [Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const epochSeconds = Object.getOwnPropertyDescriptor(Temporal.ZonedDateTime.prototype, "epochSeconds").get;
|
||||
|
||||
assert.sameValue(typeof epochSeconds, "function");
|
||||
|
||||
assert.throws(TypeError, () => epochSeconds.call(undefined), "undefined");
|
||||
assert.throws(TypeError, () => epochSeconds.call(null), "null");
|
||||
assert.throws(TypeError, () => epochSeconds.call(true), "true");
|
||||
assert.throws(TypeError, () => epochSeconds.call(""), "empty string");
|
||||
assert.throws(TypeError, () => epochSeconds.call(Symbol()), "symbol");
|
||||
assert.throws(TypeError, () => epochSeconds.call(1), "1");
|
||||
assert.throws(TypeError, () => epochSeconds.call({}), "plain object");
|
||||
assert.throws(TypeError, () => epochSeconds.call(Temporal.ZonedDateTime), "Temporal.ZonedDateTime");
|
||||
assert.throws(TypeError, () => epochSeconds.call(Temporal.ZonedDateTime.prototype), "Temporal.ZonedDateTime.prototype");
|
@ -1,14 +0,0 @@
|
||||
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-get-temporal.zoneddatetime.prototype.epochseconds
|
||||
description: The "epochSeconds" property of Temporal.ZonedDateTime.prototype
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const descriptor = Object.getOwnPropertyDescriptor(Temporal.ZonedDateTime.prototype, "epochSeconds");
|
||||
assert.sameValue(typeof descriptor.get, "function");
|
||||
assert.sameValue(descriptor.set, undefined);
|
||||
assert.sameValue(descriptor.enumerable, false);
|
||||
assert.sameValue(descriptor.configurable, true);
|
@ -48,7 +48,7 @@ const instance = new Temporal.ZonedDateTime(
|
||||
calendar,
|
||||
);
|
||||
|
||||
const fallBackTimeZone = TemporalHelpers.oneShiftTimeZone(Temporal.Instant.fromEpochSeconds(1800), -3600_000_000_000);
|
||||
const fallBackTimeZone = TemporalHelpers.oneShiftTimeZone(Temporal.Instant.fromEpochMilliseconds(1800_000), -3600_000_000_000);
|
||||
const fallBackTimeZoneObserver = TemporalHelpers.timeZoneObserver(actual, "this.timeZone", {
|
||||
getOffsetNanosecondsFor: fallBackTimeZone.getOffsetNanosecondsFor.bind(fallBackTimeZone),
|
||||
getPossibleInstantsFor: fallBackTimeZone.getPossibleInstantsFor.bind(fallBackTimeZone),
|
||||
@ -56,7 +56,7 @@ const fallBackTimeZoneObserver = TemporalHelpers.timeZoneObserver(actual, "this.
|
||||
const fallBackInstance = new Temporal.ZonedDateTime(0n, fallBackTimeZoneObserver, calendar);
|
||||
const beforeFallBackInstance = new Temporal.ZonedDateTime(-3599_000_000_000n, fallBackTimeZoneObserver, calendar);
|
||||
|
||||
const springForwardTimeZone = TemporalHelpers.oneShiftTimeZone(Temporal.Instant.fromEpochSeconds(-1800), 3600_000_000_000);
|
||||
const springForwardTimeZone = TemporalHelpers.oneShiftTimeZone(Temporal.Instant.fromEpochMilliseconds(-1800_000), 3600_000_000_000);
|
||||
const springForwardTimeZoneObserver = TemporalHelpers.timeZoneObserver(actual, "this.timeZone", {
|
||||
getOffsetNanosecondsFor: springForwardTimeZone.getOffsetNanosecondsFor.bind(springForwardTimeZone),
|
||||
getPossibleInstantsFor: springForwardTimeZone.getPossibleInstantsFor.bind(springForwardTimeZone),
|
||||
|
@ -26,7 +26,7 @@ const instance = new Temporal.ZonedDateTime(
|
||||
calendar,
|
||||
);
|
||||
|
||||
const fallBackTimeZone = TemporalHelpers.oneShiftTimeZone(Temporal.Instant.fromEpochSeconds(1800), -3600_000_000_000);
|
||||
const fallBackTimeZone = TemporalHelpers.oneShiftTimeZone(Temporal.Instant.fromEpochMilliseconds(1800_000), -3600_000_000_000);
|
||||
const fallBackInstance = new Temporal.ZonedDateTime(
|
||||
0n,
|
||||
TemporalHelpers.timeZoneObserver(actual, "this.timeZone", {
|
||||
@ -35,7 +35,7 @@ const fallBackInstance = new Temporal.ZonedDateTime(
|
||||
}),
|
||||
calendar,
|
||||
);
|
||||
const springForwardTimeZone = TemporalHelpers.oneShiftTimeZone(Temporal.Instant.fromEpochSeconds(-1800), 3600_000_000_000);
|
||||
const springForwardTimeZone = TemporalHelpers.oneShiftTimeZone(Temporal.Instant.fromEpochMilliseconds(-1800_000), 3600_000_000_000);
|
||||
const springForwardInstance = new Temporal.ZonedDateTime(
|
||||
0n,
|
||||
TemporalHelpers.timeZoneObserver(actual, "this.timeZone", {
|
||||
|
@ -8,7 +8,7 @@ features: [Temporal]
|
||||
---*/
|
||||
|
||||
var zone = new Temporal.TimeZone("+01:00");
|
||||
var inst = Temporal.Instant.fromEpochSeconds(Math.floor(Math.random() * 1000000000));
|
||||
var inst = Temporal.Instant.fromEpochMilliseconds(Math.floor(Math.random() * 1_000_000_000_000));
|
||||
var dtm = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789);
|
||||
assert.sameValue(zone.id, `${ zone }`)
|
||||
assert.sameValue(zone.getOffsetNanosecondsFor(inst), 3600000000000)
|
||||
|
@ -8,7 +8,7 @@ features: [Temporal]
|
||||
---*/
|
||||
|
||||
var zone = new Temporal.TimeZone("UTC");
|
||||
var inst = Temporal.Instant.fromEpochSeconds(Math.floor(Math.random() * 1000000000));
|
||||
var inst = Temporal.Instant.fromEpochMilliseconds(Math.floor(Math.random() * 1_000_000_000_000));
|
||||
var dtm = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789);
|
||||
assert.sameValue(zone.id, `${ zone }`)
|
||||
assert.sameValue(zone.getOffsetNanosecondsFor(inst), 0)
|
||||
|
@ -215,7 +215,7 @@ assert.sameValue(md2.monthCode, "M01");
|
||||
|
||||
// timezone.getPlainDateTimeFor()
|
||||
var tz = Temporal.TimeZone.from("UTC");
|
||||
var inst = Temporal.Instant.fromEpochSeconds(0);
|
||||
var inst = Temporal.Instant.fromEpochMilliseconds(0);
|
||||
var dt = tz.getPlainDateTimeFor(inst, obj);
|
||||
assert.sameValue(dt.getCalendar(), obj);
|
||||
|
||||
|
@ -151,7 +151,7 @@ assert.sameValue(md2.monthCode, "M02");
|
||||
|
||||
// timezone.getPlainDateTimeFor()
|
||||
var tz = Temporal.TimeZone.from("UTC");
|
||||
var instant = Temporal.Instant.fromEpochSeconds(0);
|
||||
var instant = Temporal.Instant.fromEpochMilliseconds(0);
|
||||
var dt = tz.getPlainDateTimeFor(instant, obj);
|
||||
assert.sameValue(dt.getCalendar(), obj);
|
||||
|
||||
|
@ -15,7 +15,6 @@ var epochNanos = BigInt(epochMillis) * BigInt(1000000) + BigInt(456789);
|
||||
var zdt = new Temporal.ZonedDateTime(epochNanos, tz);
|
||||
assert(zdt instanceof Temporal.ZonedDateTime);
|
||||
assert.sameValue(typeof zdt, "object");
|
||||
assert.sameValue(zdt.toInstant().epochSeconds, Math.floor(Date.UTC(1976, 10, 18, 15, 23, 30, 123) / 1000), "epochSeconds");
|
||||
assert.sameValue(zdt.toInstant().epochMilliseconds, Date.UTC(1976, 10, 18, 15, 23, 30, 123), "epochMilliseconds");
|
||||
|
||||
// Temporal.ZonedDateTime for (1976, 11, 18, 15, 23, 30, 123, 456, 789)"
|
||||
@ -34,9 +33,7 @@ assert.sameValue(zdt.second, 30);
|
||||
assert.sameValue(zdt.millisecond, 123);
|
||||
assert.sameValue(zdt.microsecond, 456);
|
||||
assert.sameValue(zdt.nanosecond, 789);
|
||||
assert.sameValue(zdt.epochSeconds, 217178610);
|
||||
assert.sameValue(zdt.epochMilliseconds, 217178610123);
|
||||
assert.sameValue(zdt.epochMicroseconds, 217178610123456n);
|
||||
assert.sameValue(zdt.epochNanoseconds, 217178610123456789n);
|
||||
assert.sameValue(zdt.dayOfWeek, 4);
|
||||
assert.sameValue(zdt.dayOfYear, 323);
|
||||
@ -96,9 +93,7 @@ assert.sameValue(zdt.second, 30);
|
||||
assert.sameValue(zdt.millisecond, 123);
|
||||
assert.sameValue(zdt.microsecond, 456);
|
||||
assert.sameValue(zdt.nanosecond, 789);
|
||||
assert.sameValue(zdt.epochSeconds, 217178610);
|
||||
assert.sameValue(zdt.epochMilliseconds, 217178610123);
|
||||
assert.sameValue(zdt.epochMicroseconds, 217178610123456n);
|
||||
assert.sameValue(zdt.epochNanoseconds, 217178610123456789n);
|
||||
assert.sameValue(zdt.dayOfWeek, 4);
|
||||
assert.sameValue(zdt.dayOfYear, 323);
|
||||
|
Loading…
x
Reference in New Issue
Block a user