fabro/apps/fabro-web/app/lib/time.ts
Bryan Helmkamp 17e59992d5 chore: remove unused verification, retros, and sessions endpoints
These endpoints had zero CLI callers and served only the web UI demo.
Verification and retros were `not_implemented` stubs in real mode;
sessions had an in-memory implementation but no CLI usage. Removing
them shrinks the API surface and eliminates ~9,000 lines of dead code.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 17:52:51 -04:00

24 lines
910 B
TypeScript

function relativeTime(seconds: number, past: boolean): string {
if (seconds < 60) return past ? "just now" : "in <1m";
const minutes = Math.floor(seconds / 60);
if (minutes < 60) return past ? `${minutes}m ago` : `in ${minutes}m`;
const hours = Math.floor(minutes / 60);
if (hours < 24) return past ? `${hours}h ago` : `in ${hours}h`;
const days = Math.floor(hours / 24);
return past ? `${days}d ago` : `in ${days}d`;
}
/**
* Format an ISO 8601 timestamp as a relative past time string (e.g. "2h ago", "3d ago").
*/
export function timeAgo(iso: string): string {
return relativeTime(Math.floor((Date.now() - new Date(iso).getTime()) / 1000), true);
}
/**
* Format an ISO 8601 timestamp as a relative future time string (e.g. "in 2h", "in 3d").
*/
export function timeUntil(iso: string): string {
return relativeTime(Math.floor((new Date(iso).getTime() - Date.now()) / 1000), false);
}