Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scheduled next run incorrect during day light savings change #112

Closed
korazy8s opened this issue Apr 16, 2021 · 0 comments
Closed

Scheduled next run incorrect during day light savings change #112

korazy8s opened this issue Apr 16, 2021 · 0 comments

Comments

@korazy8s
Copy link

When the next run date result is invalid because of day light savings time change, the next scheduled is skipped.
In the example below, the next run date would normally be 2021-03-14 02:15:00, but because of the day light savings time jump @ 2AM, the result should be 2021-03-14 03:15:00. Currently the result returned is 2021-03-21 02:15:00 which skips the next run time and causes the next scheduled run to be missed.

// at 2:15 AM every sunday
$ce = new \Cron\CronExpression('15 2 * * 0');
$nrd = $ce->getNextRunDate(new \DateTime('2021-03-08 8:15:20', new \DateTimeZone('America/Winnipeg')));
$this->assertEquals(new \DateTime('2021-03-14 3:15:00', new \DateTimeZone('America/Winnipeg')), $nrd);
// Failed asserting that two DateTime objects are equal.
// Expected :2021-03-14T03:15:00.000000-0500
// Actual   :2021-03-21T02:15:00.000000-0500
AllenJB added a commit to AllenJB/cron-expression that referenced this issue May 31, 2021
Use a cache of timezone transitions to avoid having to modify date/time objects every single time we want to check if hour is satisfied
All tests pass
dragonmantank added a commit that referenced this issue Jan 5, 2022
* DST fix (attempt 1)

* More tests and further fixes
WIP as I believe the change to HoursField::isSatisfiedBy is going to break expressions with multiple parts - but one thing at a time!

* WIP More tests and further fixes;
API change: isSatisfiedBy now requires knowledge of which direction we're travelling in to handle checking initial values correctly

* WIP Save Point - Trying to fix one thing breaks another, but I have an idea...

* WIP Abstracted NextRunDateTime which keeps track of offset changes, regardless of whether they occurred when changing minute or hour (and to persist them until a next change is made)

* WIP Fix easy fixes

* WIP More test fixes

* All current tests pass!

* Fix for issue #112;
Use a cache of timezone transitions to avoid having to modify date/time objects every single time we want to check if hour is satisfied
All tests pass

* Cleanup
All tests pass

* Cleanup
All tests pass

* Cleanup - backing out the NextRunDateTime abstraction;
All tests pass

* Cleanup;
All tests pass

* Cleanup (diff tidy, restoring deleted tests);
All tests pass

* Cleanup (diff tidy);
All tests pass

* Fix CI issues

* Fix CI issues

Co-authored-by: Chris Tankersley <chris@ctankersley.com>
dragonmantank added a commit that referenced this issue Jan 5, 2022
* DST fix (attempt 1)

* More tests and further fixes
WIP as I believe the change to HoursField::isSatisfiedBy is going to break expressions with multiple parts - but one thing at a time!

* WIP More tests and further fixes;
API change: isSatisfiedBy now requires knowledge of which direction we're travelling in to handle checking initial values correctly

* WIP Save Point - Trying to fix one thing breaks another, but I have an idea...

* WIP Abstracted NextRunDateTime which keeps track of offset changes, regardless of whether they occurred when changing minute or hour (and to persist them until a next change is made)

* WIP Fix easy fixes

* WIP More test fixes

* All current tests pass!

* Fix for issue #112;
Use a cache of timezone transitions to avoid having to modify date/time objects every single time we want to check if hour is satisfied
All tests pass

* Cleanup
All tests pass

* Cleanup
All tests pass

* Cleanup - backing out the NextRunDateTime abstraction;
All tests pass

* Cleanup;
All tests pass

* Cleanup (diff tidy, restoring deleted tests);
All tests pass

* Cleanup (diff tidy);
All tests pass

* Fix CI issues

* Fix CI issues

Co-authored-by: Chris Tankersley <chris@ctankersley.com>
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

No branches or pull requests

2 participants