MCPcopy Create free account
hub / github.com/TanStack/ai / relativeTime

Function relativeTime

examples/ts-react-chat/src/routes/threads.tsx:153–161  ·  view source on GitHub ↗
(ts: number)

Source from the content-addressed store, hash-verified

151}
152
153function relativeTime(ts: number): string {
154 const seconds = Math.floor((Date.now() - ts) / 1000)
155 if (seconds < 60) return 'just now'
156 const minutes = Math.floor(seconds / 60)
157 if (minutes < 60) return `${minutes}m ago`
158 const hours = Math.floor(minutes / 60)
159 if (hours < 24) return `${hours}h ago`
160 return `${Math.floor(hours / 24)}d ago`
161}
162
163/**
164 * Owns the thread catalog in localStorage. This is the layer the persistence

Callers 1

ThreadsRouteFunction · 0.85

Calls 1

nowMethod · 0.80

Tested by

no test coverage detected