Skip to content

fix(darwin): correct timezone offset across month/year boundaries - #4

Merged
dortort merged 1 commit into
mainfrom
fix/tz-offset-month-boundary
Aug 1, 2026
Merged

dortort merged 1 commit into
mainfrom
fix/tz-offset-month-boundary

Conversation

@dortort

@dortort dortort commented Aug 1, 2026

Copy link
Copy Markdown
Owner

What

Fix computeTimezoneOffsetMinutes (src/schedulers/darwin.ts) to stay correct across month/year boundaries.

Bug

It converted each timezone's wall clock to day*1440 + h*60 + m using day-of-month, then subtracted the two readings. When the current instant falls on different calendar days that straddle a month boundary — e.g. it's still Jul 31 in UTC/NY but already Aug 1 in Tokyo — day-of-month jumps 31 → 1 instead of 31 → 32, injecting a ~30-day (43,200-min) error.

Symptom: the computeTimezoneOffsetMinutes › produces consistent relative offsets test fails around month-end with expected -43860 to be greater than or equal to 780. This is date-triggered and pre-existing on main (it passes most days), and the same miscalculation corrupts the launchd CalendarInterval timezone adjustment for far-apart timezones around month boundaries.

Fix

Use the full year/month/day via Date.UTC(y, mo-1, d, h, m)/60000, so the subtraction is correct across month and year boundaries. Adds a regression test pinned (fake timers) to 2026-07-31T23:30Z — the exact instant that reproduced the failure.

Verification

  • npm test — 341 passed (incl. new regression test)
  • npm run typecheck / lint / build — green

🤖 Generated with Claude Code

computeTimezoneOffsetMinutes converted each timezone's wall clock to
`day*1440 + h*60 + m` using day-of-month, then subtracted the two. When the
current instant lands on different calendar days across a month boundary (e.g.
Jul 31 locally but already Aug 1 in Tokyo), day-of-month jumps 31 -> 1 instead
of 31 -> 32, injecting a ~30-day (43200-min) error — so the launchd
CalendarInterval timezone adjustment was wrong for far-apart timezones around
month ends. Use the full year/month/day via Date.UTC so the subtraction is
correct across month and year boundaries.

Add a regression test pinned (fake timers) to 2026-07-31T23:30Z, the instant
that reproduced the failure.

Confidence: high
Scope-risk: narrow
Not-tested: leap-second edge (not representable by Intl parts)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dortort
dortort merged commit 07dc58f into main Aug 1, 2026
5 checks passed
@dortort
dortort deleted the fix/tz-offset-month-boundary branch August 1, 2026 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant