2024-02-06 22:58:49 +01:00
|
|
|
import tap from 'tap';
|
|
|
|
import {parseDateTime as parse} from '../../parse/date-time.js';
|
2019-09-03 15:35:12 +02:00
|
|
|
|
2019-10-20 00:19:11 +02:00
|
|
|
const ctx = {
|
|
|
|
common: {},
|
|
|
|
opt: {},
|
|
|
|
profile: {
|
|
|
|
timezone: 'Europe/Berlin',
|
2024-02-06 22:58:49 +01:00
|
|
|
locale: 'de-DE',
|
|
|
|
},
|
|
|
|
};
|
2019-09-03 15:35:12 +02:00
|
|
|
|
2021-05-20 16:42:43 +01:00
|
|
|
tap.test('date & time parsing returns a timestamp', (t) => {
|
2024-12-07 16:16:31 +00:00
|
|
|
const iso = parse(ctx, null, '2019-08-19T20:30:00', false);
|
|
|
|
const ts = parse(ctx, null, '2019-08-19T20:30:00', true);
|
2024-02-06 22:58:49 +01:00
|
|
|
t.equal(ts, Number(new Date(iso)));
|
|
|
|
t.equal(ts, 1566239400 * 1000);
|
|
|
|
t.end();
|
|
|
|
});
|
2019-09-03 15:35:12 +02:00
|
|
|
|
2021-05-20 16:42:43 +01:00
|
|
|
tap.test('date & time parsing uses profile.timezone', (t) => {
|
2019-10-20 00:19:11 +02:00
|
|
|
const iso = parse({
|
|
|
|
...ctx,
|
2024-02-06 22:58:49 +01:00
|
|
|
profile: {...ctx.profile, timezone: 'Europe/Moscow'},
|
2024-12-07 16:16:31 +00:00
|
|
|
}, null, '2019-08-19T20:30:00', false);
|
2024-02-06 22:58:49 +01:00
|
|
|
t.equal(iso, '2019-08-19T20:30:00+03:00');
|
|
|
|
t.end();
|
|
|
|
});
|