blob: a22b6bc455c1dbf0c71f1783814ed56312140140 (
plain)
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
|
export type Date = {
year: number;
month: number;
day: number;
};
export function stringToDate(s: string): Date {
const match = s.match(/(\d{4})-(\d{2})-(\d{2})/);
if (match === null) {
throw new Error();
}
const [_, y, m, d] = match;
return { year: parseInt(y), month: parseInt(m), day: parseInt(d) };
}
export function dateToString(date: Date): string {
const y = `${date.year}`.padStart(4, "0");
const m = `${date.month}`.padStart(2, "0");
const d = `${date.day}`.padStart(2, "0");
return `${y}-${m}-${d}`;
}
export function dateToRfc3339String(date: Date): string {
// 2021-01-01T12:00:00+00:00
// TODO: currently, time part is fixed to 00:00:00.
const y = `${date.year}`.padStart(4, "0");
const m = `${date.month}`.padStart(2, "0");
const d = `${date.day}`.padStart(2, "0");
return `${y}-${m}-${d}T00:00:00+09:00`;
}
export type Revision = {
number: number;
date: Date;
remark: string;
isInternal: boolean;
};
|