blob: e04b7ba15f50cbe1fc2363c72d3a8961be790ba1 (
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
|
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 type Revision = {
number: number;
date: Date;
remark: string;
};
|