← Back to Pull requests

fix: compensate DST transitions wider than one hour #435

Closed
unknown closed this pull request without merging on Aug 12, 2026 17:13 UTC
View on GitHub
unknown unknown commented on Aug 02, 2026 21:27 UTC
Author

Fixes #419. Opening this as invited in the issue.

Problem

applyDateOperation detects a spring-forward by comparing wall-clock hours and testing for a delta of exactly 2:

const diff = currentHour - previousHour;
if (diff === 2) {
  this.dstStart = previousHour + 1;
}

That assumes the gap is one hour wide. Antarctica/Troll advances two hours on 2026-03-29, 00:00 to 03:00, so the delta is 3, the branch never fires, and dstStart stays null. A schedule inside the skipped window is then dropped for the day rather than moved past the gap:

const parser = require('cron-parser');

// America/New_York, 1-hour gap, "30 2 * * *"
//   2026-03-07 02:30
//   2026-03-08 03:30   <- compensated, still runs
//   2026-03-09 02:30

// Antarctica/Troll, 2-hour gap, "30 1 * * *"
//   2026-03-28 01:30
//   2026-03-30 01:30   <- 29 March never appears
//   2026-03-31 01:30

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:

const skippedHours = Math.floor((this.getUTCOffset() - previousOffset) / 60);
if (skippedHours >= 1) { ... }

A sub-hour transition such as Australia/Lord_Howe skips 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 - 1 stopped matching by itself once the hour advanced, whereas a multi-hour window does not. Without closing the window explicitly, 30 1 in 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

before   2026-03-28 01:30    2026-03-30 01:30     <- 29 March never fires
after    2026-03-28 01:30    2026-03-29 03:30    2026-03-30 01:30

which is the same compensation America/New_York already 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, comparing master against this branch. 23 cases change, all of them in Antarctica/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/Santiago transitions at midnight and drops an occurrence the same way, but through a different route: day-granularity jumps return from applyDateOperation before 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.

Diff: 432 lines (+324 / -108) across 5 files Reviewer: aniket-3001 Review duration: 14145m
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
0.45
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
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
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 45.2% (MEDIUM) · Higher = larger blast radius
45.2%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 17.8% · Safe to merge
17.8%