MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / formatRelativeTime

Function formatRelativeTime

apps/web/src/app/admin/components/ModelStatsTable.tsx:206–219  ·  view source on GitHub ↗
(timestamp: string | null)

Source from the content-addressed store, hash-verified

204
205 const formatRelativeTime = (timestamp: string | null) => {
206 if (!timestamp) return 'Never';
207 const date = new Date(timestamp);
208 const now = new Date();
209 const diffMs = now.getTime() - date.getTime();
210 const diffMins = Math.floor(diffMs / 60000);
211 const diffHours = Math.floor(diffMs / 3600000);
212 const diffDays = Math.floor(diffMs / 86400000);
213
214 if (diffMins < 1) return 'Just now';
215 if (diffMins < 60) return `${diffMins} minute${diffMins !== 1 ? 's' : ''} ago`;
216 if (diffHours < 24) return `${diffHours} hour${diffHours !== 1 ? 's' : ''} ago`;
217 return `${diffDays} day${diffDays !== 1 ? 's' : ''} ago`;
218 };
219
220 const buttons = (
221 <div className="flex gap-2">
222 <Button variant="outline" onClick={handleBustCache} disabled={bustCache.isPending}>

Callers 1

ModelStatsTableFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected