MCPcopy Create free account
hub / github.com/oboard/claude-code-rev / formatBriefTimestamp

Function formatBriefTimestamp

src/utils/formatBriefTimestamp.ts:16–51  ·  view source on GitHub ↗
(
  isoString: string,
  now: Date = new Date(),
)

Source from the content-addressed store, hash-verified

14 * `now` is injectable for tests.
15 */
16export function formatBriefTimestamp(
17 isoString: string,
18 now: Date = new Date(),
19): string {
20 const d = new Date(isoString)
21 if (Number.isNaN(d.getTime())) {
22 return ''
23 }
24
25 const locale = getLocale()
26 const dayDiff = startOfDay(now) - startOfDay(d)
27 const daysAgo = Math.round(dayDiff / 86_400_000)
28
29 if (daysAgo === 0) {
30 return d.toLocaleTimeString(locale, {
31 hour: 'numeric',
32 minute: '2-digit',
33 })
34 }
35
36 if (daysAgo > 0 && daysAgo < 7) {
37 return d.toLocaleString(locale, {
38 weekday: 'long',
39 hour: 'numeric',
40 minute: '2-digit',
41 })
42 }
43
44 return d.toLocaleString(locale, {
45 weekday: 'long',
46 month: 'short',
47 day: 'numeric',
48 hour: 'numeric',
49 minute: '2-digit',
50 })
51}
52
53/**
54 * Derive a BCP 47 locale tag from POSIX env vars.

Callers 2

renderToolResultMessageFunction · 0.85
HighlightedThinkingTextFunction · 0.85

Calls 2

getLocaleFunction · 0.85
startOfDayFunction · 0.85

Tested by

no test coverage detected