统一页面时间为东八区并调整活动条数

This commit is contained in:
SepComet
2026-05-07 09:36:01 +08:00
parent d46f69c9a6
commit f0397730e6
4 changed files with 43 additions and 14 deletions
+37 -3
View File
@@ -1,14 +1,34 @@
export function formatDateTime(value?: string) {
const DISPLAY_TIME_ZONE = 'Asia/Shanghai';
type DateInput = string | number | Date | undefined;
function normalizeTimestamp(value?: DateInput) {
if (!value) {
return '';
}
const time = Date.parse(value);
const time =
value instanceof Date
? value.getTime()
: typeof value === 'number'
? value
: Date.parse(value);
if (Number.isNaN(time)) {
return value;
return typeof value === 'string' ? value : '';
}
return time;
}
export function formatDateTime(value?: DateInput) {
const time = normalizeTimestamp(value);
if (time === '') {
return '';
}
return new Intl.DateTimeFormat('zh-CN', {
timeZone: DISPLAY_TIME_ZONE,
year: 'numeric',
month: '2-digit',
day: '2-digit',
@@ -18,6 +38,20 @@ export function formatDateTime(value?: string) {
}).format(new Date(time));
}
export function formatDate(value?: DateInput) {
const time = normalizeTimestamp(value);
if (time === '') {
return '';
}
return new Intl.DateTimeFormat('zh-CN', {
timeZone: DISPLAY_TIME_ZONE,
year: 'numeric',
month: '2-digit',
day: '2-digit',
}).format(new Date(time));
}
export function getLatestDate(values: string[]) {
const timestamps = values.map((value) => Date.parse(value)).filter((value) => !Number.isNaN(value));
if (timestamps.length === 0) {