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

Function formatLastSeen

packages/react/src/lib/admin-users-display.ts:37–53  ·  view source on GitHub ↗
(lastSeenAt: number | null, now: number = Date.now())

Source from the content-addressed store, hash-verified

35 * sighting) reads as "Never", not "unknown".
36 */
37export const formatLastSeen = (lastSeenAt: number | null, now: number = Date.now()): string => {
38 if (lastSeenAt === null) return "Never";
39 const delta = now - lastSeenAt;
40 if (delta < HOUR) return "Within the hour";
41 if (delta < DAY) {
42 const hours = Math.floor(delta / HOUR);
43 return hours === 1 ? "About 1 hour ago" : `About ${hours} hours ago`;
44 }
45 const days = Math.floor(delta / DAY);
46 if (days === 1) return "About 1 day ago";
47 if (days < 30) return `About ${days} days ago`;
48 return new Intl.DateTimeFormat(undefined, {
49 month: "short",
50 day: "numeric",
51 year: "numeric",
52 }).format(new Date(lastSeenAt));
53};
54
55/** The tooltip behind {@link formatLastSeen}: the exact recorded instant plus
56 * the coarseness caveat, so an operator reading "Within the hour" can see what

Callers 2

AdminUsersPageFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected