-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.test.ts
48 lines (44 loc) · 1.33 KB
/
index.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import test from "ava";
import {JsDate} from "./js-date";
import {fromJsDate, parseIso8601, timestamp} from "./index";
test("fromJsDate", t => {
const a = new JsDate();
a.setUTCFullYear(2021, 3, 30);
a.setUTCHours(13, 11, 27, 245);
t.deepEqual(
fromJsDate(a),
timestamp({year: 2021, month: 4, day: 30, hours: 13, minutes: 11, seconds: 27.245})
);
const b = new JsDate();
b.setUTCFullYear(10000, 0, 1);
b.setUTCHours(0, 0, 0, 0);
t.deepEqual(
fromJsDate(b),
timestamp({year: 10000, month: 1, day: 1, hours: 0, minutes: 0, seconds: 0})
);
t.deepEqual(
fromJsDate(new JsDate("1994-11-05T08:15:30-05:00")),
timestamp({year: 1994, month: 11, day: 5, hours: 13, minutes: 15, seconds: 30})
);
});
test("parseIso8601", t => {
t.deepEqual(
parseIso8601("2021-04-30T13:11:27.245Z"),
timestamp({year: 2021, month: 4, day: 30, hours: 13, minutes: 11, seconds: 27.245})
);
t.deepEqual(
parseIso8601("10000-01-01T00:00:00Z"),
timestamp({year: 10000, month: 1, day: 1, hours: 0})
);
t.deepEqual(
parseIso8601("1994-11-05T08:15:30-05:00"),
timestamp({
year: 1994,
month: 11,
day: 5,
hours: 13,
minutes: 15,
seconds: 30
})
);
});