2022-04-12 02:34:09 +08:00
|
|
|
export function niceDate(d: Date): string {
|
2024-08-18 19:04:51 +08:00
|
|
|
return localDateString(d).split("T")[0];
|
2022-04-12 02:34:09 +08:00
|
|
|
}
|
2023-11-03 19:04:51 +08:00
|
|
|
|
|
|
|
export function niceTime(d: Date): string {
|
2024-08-18 21:43:08 +08:00
|
|
|
return localDateString(d).split("T")[1].split(".")[0];
|
2023-11-03 19:04:51 +08:00
|
|
|
}
|
2024-07-27 17:03:42 +08:00
|
|
|
|
|
|
|
export function safeTime(d: Date): string {
|
|
|
|
return niceTime(d).replace(/:/g, "-");
|
|
|
|
}
|
2024-08-18 19:04:51 +08:00
|
|
|
|
|
|
|
export function localDateString(d: Date): string {
|
|
|
|
return d.getFullYear() +
|
|
|
|
"-" + String(d.getMonth() + 1).padStart(2, "0") +
|
|
|
|
"-" + String(d.getDate()).padStart(2, "0") +
|
|
|
|
"T" + String(d.getHours()).padStart(2, "0") +
|
|
|
|
":" + String(d.getMinutes()).padStart(2, "0") +
|
|
|
|
":" + String(d.getSeconds()).padStart(2, "0") +
|
|
|
|
"." + String(d.getMilliseconds()).padStart(3, "0");
|
|
|
|
}
|