diff options
| author | Ariel Costas Guerrero <ariel@costas.dev> | 2026-03-13 16:49:10 +0100 |
|---|---|---|
| committer | Ariel Costas Guerrero <ariel@costas.dev> | 2026-03-13 16:49:30 +0100 |
| commit | ee69c62adc5943a1dbd154df5142c0e726bdd317 (patch) | |
| tree | 5874249173aa249d4d497733ef9fc410e64ab664 /src/Enmarcha.Backend/Extensions/StopScheduleExtensions.cs | |
| parent | 90ad5395f6310da86fee9a29503e58ea74f3078b (diff) | |
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
Diffstat (limited to 'src/Enmarcha.Backend/Extensions/StopScheduleExtensions.cs')
| -rw-r--r-- | src/Enmarcha.Backend/Extensions/StopScheduleExtensions.cs | 58 |
1 files changed, 0 insertions, 58 deletions
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); - } - - /// <summary> - /// Parse GTFS time format (HH:MM:SS) which can have hours >= 24 for services past midnight - /// </summary> - 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; - } - } -} |
