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

Function formatRelativeAge

apps/desktop/src/cli/format.ts:32–45  ·  view source on GitHub ↗
(updatedAt: number)

Source from the content-addressed store, hash-verified

30}
31
32export function formatRelativeAge(updatedAt: number): string {
33 const diff = Date.now() - updatedAt
34 if (diff < 0) return 'just now'
35 const minutes = Math.floor(diff / 60_000)
36 if (minutes < 1) return 'just now'
37 if (minutes < 60) return `${minutes}m ago`
38 const hours = Math.floor(minutes / 60)
39 if (hours < 24) return `${hours}h ago`
40 const days = Math.floor(hours / 24)
41 if (days < 30) return `${days}d ago`
42 const months = Math.floor(days / 30)
43 if (months < 12) return `${months}mo ago`
44 return `${Math.floor(months / 12)}y ago`
45}
46
47export function pad(value: string, width: number): string {
48 if (value.length >= width) return value

Callers 2

cmdVaultListFunction · 0.50
cmdListFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected