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 <noreply@anthropic.com>
This commit is contained in:
@@ -81,7 +81,7 @@ struct Game: Identifiable, Codable, Hashable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var gameDate: Date {
|
var gameDate: Date {
|
||||||
dateTime.startOfDay(in: TimeZone(identifier: "UTC"))
|
Calendar.current.startOfDay(for: dateTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Alias for TripPlanningEngine compatibility
|
/// Alias for TripPlanningEngine compatibility
|
||||||
|
|||||||
@@ -87,10 +87,11 @@ struct GameDAGRouterTests {
|
|||||||
@Test("findRoutes: two feasible games returns combined route")
|
@Test("findRoutes: two feasible games returns combined route")
|
||||||
func findRoutes_twoFeasibleGames_returnsCombinedRoute() {
|
func findRoutes_twoFeasibleGames_returnsCombinedRoute() {
|
||||||
let today = calendar.startOfDay(for: TestClock.now)
|
let today = calendar.startOfDay(for: TestClock.now)
|
||||||
let game1Date = calendar.date(bySettingHour: 13, minute: 0, second: 0, of: today)!
|
let game1Date = calendar.date(bySettingHour: 12, minute: 0, second: 0, of: today)!
|
||||||
let game2Date = calendar.date(bySettingHour: 19, 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 (game1, stadium1) = makeGameAndStadium(city: "New York", date: game1Date, coord: nycCoord)
|
||||||
let (game2, stadium2) = makeGameAndStadium(city: "Philadelphia", date: game2Date, coord: phillyCoord)
|
let (game2, stadium2) = makeGameAndStadium(city: "Philadelphia", date: game2Date, coord: phillyCoord)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user