From f5249090083eb48184393a51815740fef9c2556f Mon Sep 17 00:00:00 2001 From: Maurice Date: Wed, 17 Jun 2026 15:23:35 +0200 Subject: [PATCH] fix(dashboard): show the correct reservation date regardless of timezone The upcoming-reservations widget built the date with new Date(reservation_time) .toISOString(), which reinterprets the stored naive local time as UTC and can roll the displayed day forward in non-UTC timezones (e.g. a 23:30 reservation showing the next day). Read the date and time straight from the stored string parts via splitReservationDateTime, and format the time with the shared formatTime helper so it also honours the user's 12h/24h preference. --- client/src/pages/DashboardPage.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/client/src/pages/DashboardPage.tsx b/client/src/pages/DashboardPage.tsx index 532efca7..4dbd0917 100644 --- a/client/src/pages/DashboardPage.tsx +++ b/client/src/pages/DashboardPage.tsx @@ -18,6 +18,8 @@ import { Plane, Hotel, Utensils, Clock, RefreshCw, ArrowRightLeft, Calendar, LayoutGrid, List, Ticket, X, } from 'lucide-react' +import { formatTime, splitReservationDateTime } from '../utils/formatters' +import { useSettingsStore } from '../store/settingsStore' import '../styles/dashboard.css' const GRADIENTS = [ @@ -602,6 +604,7 @@ function UpcomingTool({ items, locale, onOpen }: { items: UpcomingReservation[]; locale: string; onOpen: (tripId: number) => void }): React.ReactElement { const { t } = useTranslation() + const timeFormat = useSettingsStore(s => s.settings.time_format) return (
@@ -612,10 +615,13 @@ function UpcomingTool({ items, locale, onOpen }: { ) : (
{items.map(r => { - const when = r.reservation_time || (r.day_date ? r.day_date + 'T00:00:00' : null) - const d = when ? new Date(when) : null - const dateStr = d ? splitDate(d.toISOString().slice(0, 10), locale) : null - const timeStr = r.reservation_time ? new Date(r.reservation_time).toLocaleTimeString(locale, { hour: '2-digit', minute: '2-digit' }) : null + // Read the date/time straight from the stored string parts. Going through + // new Date(...).toISOString() reinterprets the naive local time as UTC and + // can roll the displayed day forward/back in non-UTC timezones. + const parsed = splitReservationDateTime(r.reservation_time) + const datePart = parsed.date || r.day_date || null + const dateStr = datePart ? splitDate(datePart, locale) : null + const timeStr = parsed.time ? formatTime(parsed.time, locale, timeFormat) : null const typeClass = RES_TYPE_CLASS[r.type] || 'other' return (
onOpen(r.trip_id)}>