MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / timeAgo

Function timeAgo

packages/app-core/src/components/HomeView.tsx:31–41  ·  view source on GitHub ↗

Compact "edited 3h ago" style stamp; falls back to a short date past a week.

(ts: number, now: number)

Source from the content-addressed store, hash-verified

29
30/** Compact "edited 3h ago" style stamp; falls back to a short date past a week. */
31function timeAgo(ts: number, now: number): string {
32 const mins = Math.round((now - ts) / 60000)
33 if (mins < 1) return 'just now'
34 if (mins < 60) return `${mins}m ago`
35 const hrs = Math.round(mins / 60)
36 if (hrs < 24) return `${hrs}h ago`
37 const days = Math.round(hrs / 24)
38 if (days === 1) return 'yesterday'
39 if (days < 7) return `${days}d ago`
40 return new Date(ts).toLocaleDateString(undefined, { month: 'short', day: 'numeric' })
41}
42
43/** A light landing view shown when no note is open: the few most recently
44 * edited notes plus the open tasks for today. Keyboard: ↑/↓ (and j/k in vim

Callers 1

HomeViewFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected