MCPcopy Create free account
hub / github.com/MatterAIOrg/OrbCode / formatRelativeTime

Function formatRelativeTime

src/ui/components/StatusBar.tsx:19–34  ·  view source on GitHub ↗
(isoStr?: string)

Source from the content-addressed store, hash-verified

17};
18
19function formatRelativeTime(isoStr?: string): string {
20 if (!isoStr) return "on session start";
21 const now = Date.now();
22 const target = new Date(isoStr).getTime();
23 if (Number.isNaN(target)) return "on session start";
24 const diff = target - now;
25 if (diff <= 0) return "now";
26 const sec = Math.floor(diff / 1000);
27 const min = Math.floor(sec / 60);
28 const hrs = Math.floor(min / 60);
29 const days = Math.floor(hrs / 24);
30 if (days >= 1) return `${days}d`;
31 if (hrs >= 1) return `${hrs}h${min % 60 > 0 ? ` ${min % 60}m` : ""}`;
32 if (min >= 1) return `${min}m`;
33 return "soon";
34}
35
36interface StatusBarProps {
37 modelId: string;

Callers 1

usageSummaryFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected