Skip to content

fix: do not skip midnight after daylight saving starts - #221

Open
punjabik wants to merge 1 commit into
dragonmantank:masterfrom
punjabik:fix/midnight-spring-dst
Open

fix: do not skip midnight after daylight saving starts#221
punjabik wants to merge 1 commit into
dragonmantank:masterfrom
punjabik:fix/midnight-spring-dst

Conversation

@punjabik

@punjabik punjabik commented Aug 4, 2026

Copy link
Copy Markdown

Summary

  • preserve the sign of the target-hour distance during forward calculations
  • add a regression test for a daily midnight schedule across the spring DST transition

Problem

When a spring DST offset change makes the calculated target-hour distance negative, the forward path prefixes it with another plus sign. A distance of -1 therefore becomes the modifier "+-1 hours", which PHP interprets as a positive one-hour interval.

For 0 0 * * * in Europe/Prague, starting at 2026-03-29 00:30:00 +01:00, this leaves the candidate at 01:00 instead of midnight. The next iteration then advances to March 31 and skips the valid March 30 midnight occurrence.

Passing the already signed distance unchanged produces "-1 hours" and keeps positive distances valid as well.

This is a remaining edge case related to #154, #202, and #203.

Tests

  • composer test - 176 tests, 803 assertions, 4 skipped
  • composer phpstan - no errors

Fixes #220

When an offset change makes the fixed target-hour distance negative, prefixing it with a plus sign produces a modifier such as "+-1 hours". PHP interprets that as a positive interval, so getNextRunDate() advances past the next valid midnight.

Pass the signed distance unchanged and cover the spring transition with a regression test.
@punjabik
punjabik marked this pull request as draft August 4, 2026 07:55
@punjabik
punjabik marked this pull request as ready for review August 4, 2026 07:56
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.

getNextRunDate skips the next midnight when called before a spring DST transition

1 participant