floraison / fugit

time tools (cron, parsing, durations, ...) for Ruby, rufus-scheduler, and flor
MIT License
355 stars 29 forks source link

Invalid cron (zero day of month) results in unpredictable behaviour #10

Closed hlascelles closed 5 years ago

hlascelles commented 5 years ago

Trying to create an invalid cron with a 0th day of month "works".

Fugit::Cron.parse('0 2 1 0 *')                                                                                                                                                                       
=> #<Fugit::Cron:0x00007f90279df648 @cron_s=nil, @hours=[2], @minutes=[0], @monthdays=[1], @months=[0], @original="0 2 1 0 *", @seconds=[0], @timezone=nil, @weekdays=nil, @zone=nil>

The resulting object is unusable (especially for next_time), but there was no error, and it did not return nil.

Should(n't) it do so?

jmettraux commented 5 years ago

Hello.

I prevented that for day of month and also for months themselves (month zero was ok).

Thanks a lot.

Please tell me if you spot other impossibilities and I'll do my best to prevent them.

Please tell me as well if you need a release for that.

hlascelles commented 5 years ago

Fast work, terrific. No release needed for us at the moment, it's good to know the check will be in the next version. Thanks.