2026-07-30 12:06:41 +08:00
|
|
|
import assert from "node:assert/strict";
|
|
|
|
|
import test from "node:test";
|
|
|
|
|
import {
|
|
|
|
|
formatShanghaiDate,
|
2026-08-05 11:40:29 +08:00
|
|
|
formatShanghaiToday,
|
2026-07-30 12:06:41 +08:00
|
|
|
parseStoredDate,
|
|
|
|
|
} from "../lib/date-utils.ts";
|
|
|
|
|
|
2026-08-19 15:08:17 +08:00
|
|
|
test("treats D1 and MySQL UTC timestamps as UTC and displays Beijing time", () => {
|
2026-07-30 12:06:41 +08:00
|
|
|
const stored = "2026-07-29 05:36:00";
|
|
|
|
|
assert.equal(parseStoredDate(stored).toISOString(), "2026-07-29T05:36:00.000Z");
|
|
|
|
|
assert.match(formatShanghaiDate(stored, true), /07\/29.*13:36/);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("keeps date-only deadlines on the intended Shanghai calendar date", () => {
|
|
|
|
|
assert.match(formatShanghaiDate("2026-08-12"), /08\/12/);
|
|
|
|
|
});
|
2026-08-05 11:40:29 +08:00
|
|
|
|
|
|
|
|
test("formats the dashboard date from the Shanghai calendar", () => {
|
|
|
|
|
assert.equal(formatShanghaiToday(new Date("2026-08-04T16:30:00Z")), "8月5日");
|
|
|
|
|
});
|