mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-08-03 17:01:15 +08:00
修复查看更新更新时间变化,消息时间显示月日时分
修复查看更新更新时间变化,消息时间显示月日时分
This commit is contained in:
parent
b645152255
commit
8cf0b10f56
@ -46,6 +46,18 @@ export function formatExactMessageTimestamp(value: number | string | Date, local
|
|||||||
}).format(date)
|
}).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 {
|
function coerceDate(value: number | string | Date): Date | null {
|
||||||
const date = value instanceof Date ? value : new Date(value)
|
const date = value instanceof Date ? value : new Date(value)
|
||||||
return Number.isFinite(date.getTime()) ? date : null
|
return Number.isFinite(date.getTime()) ? date : null
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user