From ee69c62adc5943a1dbd154df5142c0e726bdd317 Mon Sep 17 00:00:00 2001 From: Ariel Costas Guerrero Date: Fri, 13 Mar 2026 16:49:10 +0100 Subject: feat(routes): add realtime estimates panel with pattern-aware styling - New GET /api/stops/estimates endpoint (nano mode: tripId, patternId, estimate, delay only) - useStopEstimates hook wiring estimates to routes-$id stop panel - Pattern-aware styling: dim schedules and estimates from other patterns - Past scheduled departures shown with strikethrough instead of hidden - Persist selected pattern in URL hash (replace navigation, no history push) - Fix planner arrivals using new estimates endpoint --- .../Extensions/StopScheduleExtensions.cs | 58 ---------------------- 1 file changed, 58 deletions(-) delete mode 100644 src/Enmarcha.Backend/Extensions/StopScheduleExtensions.cs (limited to 'src/Enmarcha.Backend/Extensions/StopScheduleExtensions.cs') diff --git a/src/Enmarcha.Backend/Extensions/StopScheduleExtensions.cs b/src/Enmarcha.Backend/Extensions/StopScheduleExtensions.cs deleted file mode 100644 index 1ef7990..0000000 --- a/src/Enmarcha.Backend/Extensions/StopScheduleExtensions.cs +++ /dev/null @@ -1,58 +0,0 @@ -using Enmarcha.Backend.Types; - -namespace Enmarcha.Backend.Extensions; - -public static class StopScheduleExtensions -{ - public static DateTime? StartingDateTime(this StopArrivals.Types.ScheduledArrival stop, DateTime baseDate) - { - return ParseGtfsTime(stop.StartingTime, baseDate); - } - - public static DateTime? CallingDateTime(this StopArrivals.Types.ScheduledArrival stop, DateTime baseDate) - { - return ParseGtfsTime(stop.CallingTime, baseDate); - } - - /// - /// Parse GTFS time format (HH:MM:SS) which can have hours >= 24 for services past midnight - /// - private static DateTime? ParseGtfsTime(string timeStr, DateTime baseDate) - { - if (string.IsNullOrWhiteSpace(timeStr)) - { - return null; - } - - var parts = timeStr.Split(':'); - if (parts.Length != 3) - { - return null; - } - - if (!int.TryParse(parts[0], out var hours) || - !int.TryParse(parts[1], out var minutes) || - !int.TryParse(parts[2], out var seconds)) - { - return null; - } - - // Handle GTFS times that exceed 24 hours (e.g., 25:30:00 for 1:30 AM next day) - var days = hours / 24; - var normalizedHours = hours % 24; - - try - { - var dt = baseDate - .AddDays(days) - .AddHours(normalizedHours) - .AddMinutes(minutes) - .AddSeconds(seconds); - return dt.AddSeconds(60 - dt.Second); - } - catch - { - return null; - } - } -} -- cgit v1.3