MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / formatRelativeTime

Function formatRelativeTime

apps/cloud/src/web/pages/create-org.tsx:25–41  ·  view source on GitHub ↗
(iso: string)

Source from the content-addressed store, hash-verified

23};
24
25const formatRelativeTime = (iso: string): string => {
26 const then = new Date(iso).getTime();
27 if (Number.isNaN(then)) return "";
28 const diffMs = Date.now() - then;
29 const min = Math.floor(diffMs / 60_000);
30 if (min < 1) return "just now";
31 if (min < 60) return `${min}m ago`;
32 const hrs = Math.floor(min / 60);
33 if (hrs < 24) return `${hrs}h ago`;
34 const days = Math.floor(hrs / 24);
35 if (days < 7) return `${days}d ago`;
36 const weeks = Math.floor(days / 7);
37 if (weeks < 5) return `${weeks}w ago`;
38 const months = Math.floor(days / 30);
39 if (months < 12) return `${months}mo ago`;
40 return `${Math.floor(days / 365)}y ago`;
41};
42
43export const CreateOrgPage = () => {
44 const auth = useAuth();

Callers 1

InviterAttributionFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected