Skip to content

fix(walk): start the day at 1am when dst skips midnight - #482

Merged
spencermountain merged 1 commit into
spencermountain:devfrom
b84330808:fix-startof-day-midnight-dst
Oct 31, 2026
Merged

spencermountain merged 1 commit into
spencermountain:devfrom
b84330808:fix-startof-day-midnight-dst

Conversation

@b84330808

Copy link
Copy Markdown
Contributor

In zones where dst starts at 12am (Havana, Santiago, Cairo, Beirut, the Azores), walking the hour down to 0 stepped into the previous day, so walk() gave up and left the time where it was:

spacetime('2026-03-08T12:00:00', 'America/Havana').startOf('day').iso() // '2026-03-08T12:00:00.000-04:00'
spacetime('2026-03-07T12:00:00', 'America/Havana').endOf('day').iso()   // '2026-03-08T11:59:59.999-04:00'

When the target is skipped, it now counts from the clock time before the gap, so 12am lands on 1am and 12:17am on 1:17am. That also fixes add(1, 'day') from 12:17am the day before, which gave 12:17pm. I compared startOf/endOf/add/hour/minute results for every zone before and after: only those midnight-gap days change, and half-hour gaps like Lord Howe come out the same as before. Tests added to tests/dst/transition-setters.test.js, pinned to the 2026 rules; they fail on master and pass with the change. The full suite and the plugin suites pass.

I used Claude Code to write this change.

In zones where dst starts at 12am (Havana, Santiago, Cairo, Beirut,
the Azores), walking the hour down to 0 stepped into the previous day,
so walk() gave up and left the time where it was:

  spacetime('2026-03-08T12:00:00', 'America/Havana').startOf('day')
  // 2026-03-08T12:00:00.000-04:00

and endOf('day') on the day before ran on to noon the next day. When
the target is skipped, count to it from the clock time before the gap,
so 12am lands on 1am (and 12:17am on 1:17am).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@spencermountain
spencermountain changed the base branch from master to dev October 31, 2026 17:01
@spencermountain
spencermountain merged commit 43b198b into spencermountain:dev Oct 31, 2026
0 of 5 checks passed
@spencermountain

Copy link
Copy Markdown
Owner

thank you!
i've been working on dev branch, getting a release ready for these great fixes.
please make future PRs from dev branch, if you can. That makes it easier for me to co-develop
cheers

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.

2 participants