export function datum(value: string | Date | null | undefined): string { if (!value) return "–"; return new Intl.DateTimeFormat("de-DE", { dateStyle: "short", timeStyle: "medium", timeZone: "Europe/Berlin", }).format(new Date(value)); } export function relativ(value: string | Date | null | undefined): string { if (!value) return "–"; const diff = (new Date(value).getTime() - Date.now()) / 1000; const rtf = new Intl.RelativeTimeFormat("de", { numeric: "auto", style: "short" }); const abs = Math.abs(diff); if (abs < 60) return rtf.format(Math.round(diff), "second"); if (abs < 3600) return rtf.format(Math.round(diff / 60), "minute"); if (abs < 86400) return rtf.format(Math.round(diff / 3600), "hour"); if (abs < 30 * 86400) return rtf.format(Math.round(diff / 86400), "day"); return datum(value); } export function kurz(value: string, max = 42): string { return value.length > max ? `${value.slice(0, max - 1)}…` : value; }