mtdowling / cron-expression

CRON for PHP: Calculate the next or previous run date and determine if a CRON expression is due
http://mtdowling.com/blog/2012/06/03/cron-expressions-in-php/
MIT License
4.9k stars 335 forks source link

If result of getNextRunDate / getPreviousRunDate happens to be during DST change window, exception is thrown #149

Open eirikmik opened 7 years ago

eirikmik commented 7 years ago

If the result of getPreviousRunDate happens to be within the "missing" hour during DST change, an "Impossible CRON expression" error is thrown.

laurencei commented 7 years ago

Isnt that the expected behaviour though? The cron is not valid if the time doesnt exist?

eirikmik commented 7 years ago

The expected behaviour is to return a valid timestamp. Consider a cron string like "45 /3 " (which is the actual case which triggered the bug). I'm not asking for a time which does not exist, I'm asking for the previous run date and expect cron-expression to figure this out, not fail because it tries to instantiate an invalid DateTime.

dragonmantank commented 7 years ago

I'm trying to get a handle on this, and #148.

What time did the error occur? I've been testing various times on the current master branch and it seems to be returning the expected run times, properly hopping across the DST time switches.