fix(dlp): guard the two remaining midnight-crossing sites against host TZ - #323
Merged
Conversation
…t TZ parksapi #77: src/parks/dlp/__tests__/dining.test.ts's "rolls a past- midnight close into the next day" test failed under TZ=Pacific/Kiritimati (UTC+14), green everywhere else. Root cause is a real production bug, not a test artifact: two call sites in disneylandparis.ts (the dining-hours block in buildLiveData, and the equivalent block in buildSchedules) advance a midnight-crossing close time via `addDays(new Date(`${dateStr}T00:00:00`), 1)`. That bare Date string parses in the host's local zone, so on any host east of Paris the "add a day" step silently fails to cross the date boundary before being reformatted into Europe/Paris. A third call site (the walkthrough-hours window check) already carries a fix and an explicit warning comment about this exact trap, landed under #63 ("Guard against the UTC-date-as-local-day trap library-wide") — these two were simply missed by that sweep. Same fix: route through shiftDateString(), which anchors at noon UTC so no offset can push it across a boundary. Added a TZ-parameterised regression test at each site (UTC, Pacific/ Kiritimati, Pacific/Auckland, Asia/Tokyo, America/Los_Angeles), mirroring the pattern already used for shiftDateString's own test in datetime.test.ts, so this is caught by `npm test` on any host without needing an external TZ override. Full suite (2047 tests) verified green under TZ=Pacific/Kiritimati, TZ=Pacific/Midway, and the default host TZ.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
parksapi #77:
dining.test.ts's "rolls a past-midnight close into thenext day" test fails under
TZ=Pacific/Kiritimati(UTC+14), green underUTC, America/New_York, Europe/Paris, Asia/Tokyo.
Root cause turned out to be a real production bug, not a test artifact.
Two call sites in
disneylandparis.ts— the dining-hours block inbuildLiveData(), and the equivalent block inbuildSchedules()— advancea midnight-crossing close time via:
That bare Date string parses in the host's local zone, not the park's.
On any host east of Paris, "add a day" can silently fail to cross the date
boundary before the result gets reformatted into
Europe/Paris.A third call site in the same file (the walkthrough-hours window check)
already carries the fix and an explicit warning comment about this exact
trap, landed under #63 ("Guard against the UTC-date-as-local-day trap
library-wide"). These two were simply missed by that sweep.
Fix
Route both remaining sites through
shiftDateString()(already importedin this file, already used at the walkthrough site) instead of the bare
new Date()+addDays+formatInTimezoneroundtrip. It anchors at noonUTC, so no offset or DST shift can push it across a date boundary.
Testing
UTC,Pacific/Kiritimati,Pacific/Auckland,Asia/Tokyo,America/Los_Angeles) — the sameprocess.env.TZloop pattern alreadyused for
shiftDateString's own regression test indatetime.test.ts.Self-contained: catches a regression on
npm testfrom any host, noexternal
TZoverride needed.TZ=Pacific/Kiritimati,TZ=Pacific/Midway, and the default host TZ — swept the whole suite,not just DLP, per the issue's suggestion. No other host-TZ-dependent
flakes found.
tsc --noEmitandnpm run buildclean.Note: "#77" above refers to the ThemeParks/programme tracking issue, not a
parksapi-repo issue — no
Closeskeyword used here since that issue livesin a different repo and GitHub's auto-close only works within the same
repo. Tracked and closed manually on the programme board.
Test plan
🤖 Generated with Claude Code