Initial commit: KOC LOOP platform

This commit is contained in:
巫凤萍
2026-07-30 12:06:41 +08:00
commit d2cde2c9b2
98 changed files with 44076 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
export function parseStoredDate(value: string) {
const trimmed = value.trim();
const normalized = /^\d{4}-\d{2}-\d{2}$/.test(trimmed)
? `${trimmed}T00:00:00+08:00`
: /^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?$/.test(
trimmed,
)
? `${trimmed.replace(" ", "T")}Z`
: trimmed;
return new Date(normalized);
}
export function formatShanghaiDate(
value?: string | null,
withTime = false,
) {
if (!value) return "—";
const date = parseStoredDate(value);
if (Number.isNaN(date.getTime())) return value;
return new Intl.DateTimeFormat("zh-CN", {
timeZone: "Asia/Shanghai",
month: "2-digit",
day: "2-digit",
...(withTime ? { hour: "2-digit", minute: "2-digit" } : {}),
}).format(date);
}