MCPcopy Create free account
hub / github.com/SethGammon/Citadel / relativeTime

Function relativeTime

scripts/dashboard.js:117–131  ·  view source on GitHub ↗
(timestamp, now = new Date())

Source from the content-addressed store, hash-verified

115 return `${text.slice(0, Math.max(0, max - 3))}...`;
116}
117
118function relativeTime(timestamp, now = new Date()) {
119 if (!timestamp) return 'unknown';
120 const date = timestamp instanceof Date ? timestamp : new Date(timestamp);
121 if (Number.isNaN(date.getTime())) return String(timestamp);
122
123 const diffMs = Math.max(0, now.getTime() - date.getTime());
124 const diffSec = Math.floor(diffMs / 1000);
125 if (diffSec < 60) return 'just now';
126 const diffMin = Math.floor(diffSec / 60);
127 if (diffMin < 60) return `${diffMin} min ago`;
128 const diffHr = Math.floor(diffMin / 60);
129 if (diffHr < 24) return `${diffHr} hr ago`;
130 const diffDays = Math.floor(diffHr / 24);
131 return `${diffDays} day${diffDays === 1 ? '' : 's'} ago`;
132}
133
134function extractDirection(content) {

Callers 5

readRecentActivityFunction · 0.85
readHookActivityFunction · 0.85
classifyHookProblemFunction · 0.85
collectDashboardFunction · 0.85
test-dashboard.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected