ago
When something happened, as a page says it: minutes, hours or days ago, then the date.
export function ago(ts: number, now = Date.now()): string { const s = Math.max(0, Math.round((now - ts) / 1000)); if (s < 60) return "just now"; if (s < 3600) return `${Math.round(s / 60)} min ago`; if (s < 86400) return `${Math.round(s / 3600)}h ago`; if (s < 86400 * 14) return `${Math.round(s / 86400)}d ago`; return new Date(ts).toISOString().slice(0, 10); }
used by
- tcmts.hub.pages.AttestationItem
- tcmts.hub.pages.FeedItem
- tcmts.hub.pages.LibraryPage
- tcmts.hub.pages.ProfilePage
- tcmts.share.BranchesPage
- tcmts.share.CommentView
- tcmts.share.ContributionPage
- tcmts.share.ContributionsPage
- tcmts.share.DefinitionView
- tcmts.share.HistoryPage
- tcmts.share.NamespaceView
- tcmts.share.PeoplePage