e4dcfc49aa
Tests / Import Check (Python 3.13) (push) Has been cancelled
Tests / Import Check (Python 3.14) (push) Has been cancelled
Tests / Python Tests (Python 3.11) (push) Has been cancelled
Tests / Python Tests (Python 3.12) (push) Has been cancelled
Tests / Python Tests (Python 3.14) (push) Has been cancelled
Tests / Test Summary (push) Has been cancelled
Tests / Lint and Format (push) Has been cancelled
Tests / Web Node Tests (push) Has been cancelled
Tests / Import Check (Python 3.11) (push) Has been cancelled
Tests / Import Check (Python 3.12) (push) Has been cancelled
Tests / Python Tests (Python 3.13) (push) Has been cancelled
26 lines
619 B
TypeScript
26 lines
619 B
TypeScript
export type Language = "en" | "zh";
|
|
|
|
export function getLocale(lang: Language): string {
|
|
return lang === "zh" ? "zh-CN" : "en-US";
|
|
}
|
|
|
|
export function formatDate(
|
|
date: Date,
|
|
lang: Language,
|
|
options: Intl.DateTimeFormatOptions = {
|
|
year: "numeric",
|
|
month: "short",
|
|
day: "numeric",
|
|
},
|
|
): string {
|
|
return new Intl.DateTimeFormat(getLocale(lang), options).format(date);
|
|
}
|
|
|
|
export function formatTime(
|
|
date: Date,
|
|
lang: Language,
|
|
options: Intl.DateTimeFormatOptions = { hour: "2-digit", minute: "2-digit" },
|
|
): string {
|
|
return new Intl.DateTimeFormat(getLocale(lang), options).format(date);
|
|
}
|