diff --git a/src/lib/hafas-time.ts b/src/lib/hafas-time.ts index 79dd32b..897ac2a 100644 --- a/src/lib/hafas-time.ts +++ b/src/lib/hafas-time.ts @@ -2,9 +2,14 @@ // HAFAS returns times in Vienna (CET/CEST). This module provides correct parsing // regardless of the server or browser timezone. -// Helper: get the offset (in minutes) from UTC for a given instant in a specific IANA timezone. -// Reads the hour via Intl.DateTimeFormat in both UTC and the target timezone, then -// computes the difference. Handles midnight wraparound (e.g. UTC 23:xx → TZ 01:xx). +// Helper: get the offset (in minutes) from UTC for a given instant in a specific +// IANA timezone. +// +// CAVEAT — Hour-level precision only. This helper reads the hour via +// Intl.DateTimeFormat (hour part only), so it returns incorrect results for +// timezones with fractional-hour offsets (e.g. India +05:30, Nepal +05:45). +// It is designed exclusively for "Europe/Vienna" (CET/CEST), which only uses +// full-hour offsets (+01:00 / +02:00). Do not reuse for other timezones. function getTimezoneOffsetMinutes(instant: Date, tz: string): number { const getHour = (timeZone: string) => { const parts = new Intl.DateTimeFormat("en-US", {