From ce734b6c63f6068dbc8dddb8b861be82b4f5e494 Mon Sep 17 00:00:00 2001 From: Trey t Date: Fri, 27 Feb 2026 18:59:54 -0600 Subject: [PATCH] fix: revert gameDate to local timezone and update DAG router test timing The hardening pass incorrectly changed Game.gameDate to use UTC, which broke timezone-dependent departure date calculations in ScenarioDPlanner. Also widened the DAG router test's same-day game gap to account for the new 3-hour game duration in canTransition. Co-Authored-By: Claude Opus 4.6 --- SportsTime/Core/Models/Domain/Game.swift | 2 +- SportsTimeTests/Planning/GameDAGRouterTests.swift | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/SportsTime/Core/Models/Domain/Game.swift b/SportsTime/Core/Models/Domain/Game.swift index 44dceae..975d49e 100644 --- a/SportsTime/Core/Models/Domain/Game.swift +++ b/SportsTime/Core/Models/Domain/Game.swift @@ -81,7 +81,7 @@ struct Game: Identifiable, Codable, Hashable { } var gameDate: Date { - dateTime.startOfDay(in: TimeZone(identifier: "UTC")) + Calendar.current.startOfDay(for: dateTime) } /// Alias for TripPlanningEngine compatibility diff --git a/SportsTimeTests/Planning/GameDAGRouterTests.swift b/SportsTimeTests/Planning/GameDAGRouterTests.swift index 97718c6..e8235bb 100644 --- a/SportsTimeTests/Planning/GameDAGRouterTests.swift +++ b/SportsTimeTests/Planning/GameDAGRouterTests.swift @@ -87,10 +87,11 @@ struct GameDAGRouterTests { @Test("findRoutes: two feasible games returns combined route") func findRoutes_twoFeasibleGames_returnsCombinedRoute() { let today = calendar.startOfDay(for: TestClock.now) - let game1Date = calendar.date(bySettingHour: 13, minute: 0, second: 0, of: today)! - let game2Date = calendar.date(bySettingHour: 19, minute: 0, second: 0, of: today)! + let game1Date = calendar.date(bySettingHour: 12, minute: 0, second: 0, of: today)! + let game2Date = calendar.date(bySettingHour: 20, minute: 0, second: 0, of: today)! - // NYC to Philly is ~95 miles, ~1.5 hours - very feasible same day + // NYC to Philly is ~95 miles, ~1.5 hours - feasible same day + // With ~3h game duration + 2h post-game buffer, departure ~17:00, arrival ~18:30, game at 20:00 let (game1, stadium1) = makeGameAndStadium(city: "New York", date: game1Date, coord: nycCoord) let (game2, stadium2) = makeGameAndStadium(city: "Philadelphia", date: game2Date, coord: phillyCoord)