previous_time did not work properly for the last days of months (not just for 29th of Februray, but for like 31st of October as well), for example:
Fugit::Cron.parse('0 20 31 oct *').previous_time(Time.parse('2019-11-01 04:00')).to_s
=> "2018-10-31 20:00:00 +0100"
As you can see the year is off by one. This is because dec_month had a bug, where it decreased the current time with one more day then necessary (this is tricky, because hours are indexed from 0, but days are from 1). Also the current dec_month implementation did not set the hours, minutes and seconds, so anything after '2019-10-31 04:00' was inaccessible with previous_time.
After this change, previous_time works properly:
Fugit::Cron.parse('0 20 31 oct *').previous_time(Time.parse('2019-11-01 04:00')).to_s
=> "2019-10-31 20:00:00 +0100"
previous_time
did not work properly for the last days of months (not just for 29th of Februray, but for like 31st of October as well), for example:As you can see the year is off by one. This is because
dec_month
had a bug, where it decreased the current time with one more day then necessary (this is tricky, because hours are indexed from 0, but days are from 1). Also the currentdec_month
implementation did not set the hours, minutes and seconds, so anything after '2019-10-31 04:00' was inaccessible withprevious_time
.After this change,
previous_time
works properly: