MCPcopy Create free account
hub / github.com/experdot/pointer / formatSemanticDateTime

Function formatSemanticDateTime

src/renderer/src/utils/dateTime.ts:13–32  ·  view source on GitHub ↗
(value: DateLike)

Source from the content-addressed store, hash-verified

11}
12
13export 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
34export function formatLongDateTime(value: DateLike): string {
35 const date = parseDateLike(value)

Callers 1

DateTimeTextFunction · 0.90

Calls 2

parseDateLikeFunction · 0.85
formatAbsoluteDateFunction · 0.85

Tested by

no test coverage detected