fix(transport): guard non-finite dates in trip-map duration

This commit is contained in:
Konstantinos Thermos
2026-07-24 10:22:35 +03:00
committed by Maurice
parent 7bd9e08016
commit fce26618a1
3 changed files with 32 additions and 0 deletions
@@ -51,6 +51,11 @@ function parseInTz(isoLocal: string, tz: string): number {
const [y, mo, d] = datePart.split('-').map(Number)
const [h, mi] = (timePart || '00:00').split(':').map(Number)
const guess = Date.UTC(y, mo - 1, d, h, mi)
// A malformed date/time (e.g. an imported booking whose time is missing its
// minutes) makes Date.UTC NaN; bail before formatToParts, which throws on a
// non-finite date and would blank the whole trip. computeDuration's finiteness
// check then drops the duration cleanly.
if (!Number.isFinite(guess)) return NaN
const fmt = new Intl.DateTimeFormat('en-US', {
timeZone: tz, hour12: false,
year: 'numeric', month: '2-digit', day: '2-digit',