mirror of https://github.com/tc39/test262.git
Test basic functionality of Temporal.Instant.from
This commit is contained in:
parent
4fdb4ee52f
commit
9cd27beb12
|
@ -0,0 +1,59 @@
|
||||||
|
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-temporal.instant.from
|
||||||
|
description: Basic functionality of Temporal.Instant.from
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const baseValue = 217_178_580_000_000_000n;
|
||||||
|
|
||||||
|
let instant = Temporal.Instant.from("1976-11-18T15:23Z");
|
||||||
|
assert.sameValue(
|
||||||
|
instant.epochNanoseconds,
|
||||||
|
baseValue,
|
||||||
|
"ISO string with UTC designator and minutes precision"
|
||||||
|
);
|
||||||
|
|
||||||
|
instant = Temporal.Instant.from("1976-11-18T15:23:30Z");
|
||||||
|
assert.sameValue(
|
||||||
|
instant.epochNanoseconds,
|
||||||
|
baseValue + 30_000_000_000n,
|
||||||
|
"ISO string with UTC designator and seconds precision"
|
||||||
|
);
|
||||||
|
|
||||||
|
instant = Temporal.Instant.from("1976-11-18T15:23:30.123Z");
|
||||||
|
assert.sameValue(
|
||||||
|
instant.epochNanoseconds,
|
||||||
|
baseValue + 30_123_000_000n,
|
||||||
|
"ISO string with UTC designator and milliseconds precision"
|
||||||
|
);
|
||||||
|
|
||||||
|
instant = Temporal.Instant.from("1976-11-18T15:23:30.123456Z");
|
||||||
|
assert.sameValue(
|
||||||
|
instant.epochNanoseconds,
|
||||||
|
baseValue + 30_123_456_000n,
|
||||||
|
"ISO string with UTC designator and microseconds precision"
|
||||||
|
);
|
||||||
|
|
||||||
|
instant = Temporal.Instant.from("1976-11-18T15:23:30.123456789Z");
|
||||||
|
assert.sameValue(
|
||||||
|
instant.epochNanoseconds,
|
||||||
|
baseValue + 30_123_456_789n,
|
||||||
|
"ISO string with UTC designator and nanoseconds precision"
|
||||||
|
);
|
||||||
|
|
||||||
|
instant = Temporal.Instant.from("1976-11-18T15:23-01:00");
|
||||||
|
assert.sameValue(
|
||||||
|
instant.epochNanoseconds,
|
||||||
|
baseValue + 3600_000_000_000n,
|
||||||
|
"ISO string with negative UTC offset"
|
||||||
|
);
|
||||||
|
|
||||||
|
instant = Temporal.Instant.from("1976-11-18T15:23+01:00");
|
||||||
|
assert.sameValue(
|
||||||
|
instant.epochNanoseconds,
|
||||||
|
baseValue - 3600_000_000_000n,
|
||||||
|
"ISO string with positive UTC offset"
|
||||||
|
);
|
Loading…
Reference in New Issue