修复查看更新更新时间变化,消息时间显示月日时分

修复查看更新更新时间变化,消息时间显示月日时分
This commit is contained in:
zhb 2026-06-28 01:55:58 +08:00 committed by GitHub
parent b645152255
commit 8cf0b10f56
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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