From 674fe965550444db87edc7937ff6932e1a918d9d Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 27 Jun 2025 23:39:31 +0900 Subject: feat(meta): rename vhosts/ directory to services/ --- services/blog/nuldoc-src/revision.ts | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 services/blog/nuldoc-src/revision.ts (limited to 'services/blog/nuldoc-src/revision.ts') diff --git a/services/blog/nuldoc-src/revision.ts b/services/blog/nuldoc-src/revision.ts new file mode 100644 index 00000000..a22b6bc4 --- /dev/null +++ b/services/blog/nuldoc-src/revision.ts @@ -0,0 +1,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; +}; -- cgit v1.2.3-70-g09d2