From 8cf0b10f5609922811198287063a24fb99370c59 Mon Sep 17 00:00:00 2001 From: zhb <50901800+zhbdesign@users.noreply.github.com> Date: Sun, 28 Jun 2026 01:55:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9F=A5=E7=9C=8B=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=9B=B4=E6=96=B0=E6=97=B6=E9=97=B4=E5=8F=98=E5=8C=96?= =?UTF-8?q?=EF=BC=8C=E6=B6=88=E6=81=AF=E6=97=B6=E9=97=B4=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=9C=88=E6=97=A5=E6=97=B6=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复查看更新更新时间变化,消息时间显示月日时分 --- desktop/src/lib/formatMessageTimestamp.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/desktop/src/lib/formatMessageTimestamp.ts b/desktop/src/lib/formatMessageTimestamp.ts index 65d71877..2ff72d77 100644 --- a/desktop/src/lib/formatMessageTimestamp.ts +++ b/desktop/src/lib/formatMessageTimestamp.ts @@ -46,6 +46,18 @@ export function formatExactMessageTimestamp(value: number | string | Date, local }).format(date) } +export function formatMessageHoverTime( + value: number | string | Date, + locale: Locale, + now = Date.now(), +): string { + const date = coerceDate(value) + if (!date) return '' + return isSameLocalYear(date, new Date(now)) + ? formatMonthDayTime(date, locale) + : formatYearMonthDayTime(date, locale) +} + function coerceDate(value: number | string | Date): Date | null { const date = value instanceof Date ? value : new Date(value) return Number.isFinite(date.getTime()) ? date : null