some more styling to the frontend

This commit is contained in:
jenz
2026-08-24 21:52:29 +02:00
parent 28b4e957ea
commit 09107047b9
17 changed files with 275 additions and 147 deletions
@@ -12,3 +12,19 @@ export function diffMinutes(startStr: string, endStr: string | null): number | n
const end = parseDbDate(endStr);
return Math.round((end.getTime() - start.getTime()) / 60000);
}
// "2h ago", "3d ago", etc. — used for "last connected" displays.
export function formatRelativeTime(dbDateStr: string | null): string {
if (!dbDateStr) return '—';
const diffMs = Date.now() - parseDbDate(dbDateStr).getTime();
const diffMin = Math.round(diffMs / 60_000);
if (diffMin < 1) return 'just now';
if (diffMin < 60) return `${diffMin}m ago`;
const diffHr = Math.round(diffMin / 60);
if (diffHr < 24) return `${diffHr}h ago`;
const diffDay = Math.round(diffHr / 24);
if (diffDay < 30) return `${diffDay}d ago`;
const diffMonth = Math.round(diffDay / 30);
if (diffMonth < 12) return `${diffMonth}mo ago`;
return `${Math.round(diffMonth / 12)}y ago`;
}