fix: compensate DST transitions wider than one hour #435
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 432 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.363
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #435"
general
weight: 0.35
aniket-3001
Fixes #419. Opening this as invited in the issue.
Problem
applyDateOperationdetects a spring-forward by comparing wall-clock hours and testing for a delta of exactly 2:That assumes the gap is one hour wide.
Antarctica/Trolladvances two hours on 2026-03-29, 00:00 to 03:00, so the delta is 3, the branch never fires, anddstStartstaysnull. A schedule inside the skipped window is then dropped for the day rather than moved past the gap:For a daily job that is a silently missed execution rather than a late one.
Changes
Detection derives the gap from the change in UTC offset, which is exact for any width:
A sub-hour transition such as
Australia/Lord_Howeskips no whole wall-clock hour, so it still records nothing, as before.Matching considers every skipped hour rather than only the one immediately before the current one, since Troll skips both 01:00 and 02:00. For a one-hour gap the loop runs exactly once and behaves as it did.
That second change removes an accidental property of the old test:
dstStart === currentHour - 1stopped matching by itself once the hour advanced, whereas a multi-hour window does not. Without closing the window explicitly,30 1in Troll matches 03:30, then 04:30, then 05:30. I close it on hour steps only, because the minutes within the compensating hour still have to match the skipped hour, which is what keeps/20 3 *firing at 04:00, 04:20 and 04:40 in the existing Athens test.Result
which is the same compensation
America/New_Yorkalready performs for its one-hour gap.Verification
The existing suite passes unchanged. Four regression tests are added in the style of the existing DST block: three fail without this change, and the fourth pins Lord Howe's sub-hour behaviour so a later change cannot start compensating a gap that skips no whole hour. 303 of 303 pass with the change.
Because this touches
#matchHour, I swept 5,865 combinations of 23 expressions across 17 timezones and 15 starting instants, in both directions, comparingmasteragainst this branch. 23 cases change, all of them inAntarctica/Troll, the only zone in the set with a two-hour gap. Nothing moves in the other 16, including Athens, Lord Howe, Chatham, Havana, Tehran and the fall-back cases.Out of scope
America/Santiagotransitions at midnight and drops an occurrence the same way, but through a different route: day-granularity jumps return fromapplyDateOperationbefore any DST detection runs. I have left that separate rather than widening this change.---
Found while porting this library to Go and comparing the two implementations on generated input. Happy to adjust the approach if you would rather solve it another way.