poliander / cron

Parse and validate crontab expressions in PHP
https://github.com/poliander/cron
GNU General Public License v3.0
63 stars 10 forks source link

if Cron('1 0 * * *'), #3

Closed marshhj closed 7 years ago

marshhj commented 7 years ago

if Cron('1 0 *'), getNext() will return next day 00:00:00 ? why not 00:01:00 ???

poliander commented 7 years ago

Thank you very much for pointing this one out.

poliander commented 7 years ago

Fixed in version 1.2.1

marshhj commented 7 years ago

Thanks for fixing! But the bug still exists........ And the fix bring new bugs.....

  1. Cron('1 0 *'), getNext() will return next day 00:00:00 still exists !!!
  2. Cron('0 0 *'), getNext() will return the day after tomorrow 00:00:00 !!!
poliander commented 7 years ago

I'll look again into this today.

poliander commented 7 years ago

Okay, you're completely right - thank you again. The getNext() calculation was flawed when crossing month boundaries. I admit there should be more unit tests for that particular method.

The error should be fixed in current master branch. Would you be so kind and do a test? I also added another unit test for when "1 0 *" goes into next month.

poliander commented 7 years ago

Fixed in version 1.2.2