MCPcopy Create free account
hub / github.com/AmazingAng/PolyWorld / getRelativeTime

Function getRelativeTime

src/components/Header.tsx:47–55  ·  view source on GitHub ↗
(iso: string)

Source from the content-addressed store, hash-verified

45}
46
47function getRelativeTime(iso: string): { text: string; stale: boolean } {
48 const diff = Date.now() - new Date(iso).getTime();
49 const secs = Math.floor(diff / 1000);
50 if (secs < 60) return { text: `${secs}s ago`, stale: false };
51 const mins = Math.floor(secs / 60);
52 if (mins < 5) return { text: `${mins}m ago`, stale: false };
53 if (mins < 60) return { text: `${mins}m ago`, stale: true };
54 return { text: `${Math.floor(mins / 60)}h ago`, stale: true };
55}
56
57function UTCClock() {
58 const [time, setTime] = useState("");

Callers 1

HeaderFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected