diff --git a/frontend/src/utils/datetime.ts b/frontend/src/utils/datetime.ts index 8719a1d..a041797 100644 --- a/frontend/src/utils/datetime.ts +++ b/frontend/src/utils/datetime.ts @@ -17,6 +17,17 @@ const BEIJING_CLOCK = new Intl.DateTimeFormat('zh-CN', { hour12: false, }) +const BEIJING_DATETIME_SEC = new Intl.DateTimeFormat('zh-CN', { + timeZone: 'Asia/Shanghai', + year: 'numeric', + month: '2-digit', + day: '2-digit', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + hour12: false, +}) + /** fmtBeijingTime 任意时间戳 → 北京时间「YYYY/MM/DD HH:mm」(无秒);空/非法输入返回空串。 */ export function fmtBeijingTime(raw: string | number | Date | null | undefined): string { if (raw === null || raw === undefined || raw === '') return '' @@ -32,3 +43,11 @@ export function fmtBeijingClock(raw: string | number | Date | null | undefined): if (Number.isNaN(date.getTime())) return '' return BEIJING_CLOCK.format(date) } + +/** fmtBeijingTimeSec 北京时间「YYYY/MM/DD HH:mm:ss」(带秒;签到明细等需秒级精度的场景)。 */ +export function fmtBeijingTimeSec(raw: string | number | Date | null | undefined): string { + if (raw === null || raw === undefined || raw === '') return '' + const date = raw instanceof Date ? raw : new Date(raw) + if (Number.isNaN(date.getTime())) return '' + return BEIJING_DATETIME_SEC.format(date) +} diff --git a/frontend/src/views/training/components/SignPanel.vue b/frontend/src/views/training/components/SignPanel.vue index d67de14..e6cb7bb 100644 --- a/frontend/src/views/training/components/SignPanel.vue +++ b/frontend/src/views/training/components/SignPanel.vue @@ -114,6 +114,8 @@ + +