You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
1.3 KiB
JavaScript
70 lines
1.3 KiB
JavaScript
"use strict";
|
|
|
|
const { Temporal } = require("@js-temporal/polyfill");
|
|
const test = require("tape");
|
|
|
|
const fromTemporal = require("../../../src/storage-encoder/type-adapters/from-temporal");
|
|
|
|
const zonedTemporal = Temporal.ZonedDateTime.from("2021-11-27T23:43:32.81701281+01:00[Europe/Amsterdam]");
|
|
const unzonedTemporal = Temporal.Instant.from("2021-11-27T22:43:32.821012817Z");
|
|
|
|
test("unzoned Temporal -> unzoned", (test) => {
|
|
test.deepEqual(fromTemporal(unzonedTemporal, false), {
|
|
millisecond: 821,
|
|
second: 32,
|
|
minute: 43,
|
|
hour: 22,
|
|
day: 27,
|
|
month: 11,
|
|
year: 2021,
|
|
timezone: undefined
|
|
});
|
|
|
|
test.end();
|
|
});
|
|
|
|
test("unzoned Temporal -> zoned", (test) => {
|
|
test.deepEqual(fromTemporal(unzonedTemporal, true), {
|
|
millisecond: 821,
|
|
second: 32,
|
|
minute: 43,
|
|
hour: 22,
|
|
day: 27,
|
|
month: 11,
|
|
year: 2021,
|
|
timezone: 'UTC'
|
|
});
|
|
|
|
test.end();
|
|
});
|
|
|
|
test("zoned Temporal -> unzoned", (test) => {
|
|
test.deepEqual(fromTemporal(zonedTemporal, false), {
|
|
millisecond: 817,
|
|
second: 32,
|
|
minute: 43,
|
|
hour: 22,
|
|
day: 27,
|
|
month: 11,
|
|
year: 2021,
|
|
timezone: undefined
|
|
});
|
|
|
|
test.end();
|
|
});
|
|
|
|
test("zoned Temporal -> zoned", (test) => {
|
|
test.deepEqual(fromTemporal(zonedTemporal, true), {
|
|
millisecond: 817,
|
|
second: 32,
|
|
minute: 43,
|
|
hour: 23,
|
|
day: 27,
|
|
month: 11,
|
|
year: 2021,
|
|
timezone: 'Europe/Amsterdam'
|
|
});
|
|
|
|
test.end();
|
|
});
|