fix(07): WR-03 replace dead try/catch in formatDateTime with isNaN guard
Tessera CI/CD / Lint & Type Check (push) Waiting to run
Tessera CI/CD / Tests (push) Blocked by required conditions
Tessera CI/CD / Build & Deploy (push) Blocked by required conditions

new Date() never throws so the catch was unreachable. Invalid dates rendered
as NaN.NaN.NaN, NaN:NaN Uhr. Use isNaN(d.getTime()) guard to fall back to
the raw string instead.
This commit is contained in:
2026-06-27 17:21:51 +02:00
parent 49eab55abe
commit 338655c57b
@@ -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 {