diff --git a/apps/web/src/app/(portal)/modules/dkv-fleet/components/InvoiceHistoryTable.tsx b/apps/web/src/app/(portal)/modules/dkv-fleet/components/InvoiceHistoryTable.tsx index bf21fca..f76d2bd 100644 --- a/apps/web/src/app/(portal)/modules/dkv-fleet/components/InvoiceHistoryTable.tsx +++ b/apps/web/src/app/(portal)/modules/dkv-fleet/components/InvoiceHistoryTable.tsx @@ -26,17 +26,17 @@ function DownloadIcon() { /** Formats an ISO date string as "26.06.2026, 14:32 Uhr" */ function formatDateTime(isoString: string): string { - try { - const d = new Date(isoString); - const day = String(d.getDate()).padStart(2, '0'); - const month = String(d.getMonth() + 1).padStart(2, '0'); - const year = d.getFullYear(); - const hours = String(d.getHours()).padStart(2, '0'); - const minutes = String(d.getMinutes()).padStart(2, '0'); - return `${day}.${month}.${year}, ${hours}:${minutes} Uhr`; - } catch { - return isoString; - } + const d = new Date(isoString); + // new Date() never throws — it returns an Invalid Date object for bad input. + // Check explicitly so malformed strings fall back gracefully instead of + // rendering as "NaN.NaN.NaN, NaN:NaN Uhr" (WR-03). + if (isNaN(d.getTime())) return isoString; + const day = String(d.getDate()).padStart(2, '0'); + const month = String(d.getMonth() + 1).padStart(2, '0'); + const year = d.getFullYear(); + const hours = String(d.getHours()).padStart(2, '0'); + const minutes = String(d.getMinutes()).padStart(2, '0'); + return `${day}.${month}.${year}, ${hours}:${minutes} Uhr`; } interface InvoiceHistoryTableProps {