(value: DateLike)
| 11 | } |
| 12 | |
| 13 | export function formatSemanticDateTime(value: DateLike): string { |
| 14 | const date = parseDateLike(value) |
| 15 | if (!date) return '-' |
| 16 | |
| 17 | const now = dayjs().locale('zh-cn') |
| 18 | if (date.isAfter(now)) { |
| 19 | return formatAbsoluteDate(date, now) |
| 20 | } |
| 21 | |
| 22 | if (date.isSame(now, 'day')) { |
| 23 | return date.format('HH:mm') |
| 24 | } |
| 25 | |
| 26 | const dayDiff = now.startOf('day').diff(date.startOf('day'), 'day') |
| 27 | if (dayDiff >= 1 && dayDiff <= 6) { |
| 28 | return `${dayDiff}天前` |
| 29 | } |
| 30 | |
| 31 | return formatAbsoluteDate(date, now) |
| 32 | } |
| 33 | |
| 34 | export function formatLongDateTime(value: DateLike): string { |
| 35 | const date = parseDateLike(value) |
no test coverage detected