floraison / fugit

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

Fugit::Cron#next_time works incorrectly with "every second day" and "mon-fri" combo #75

Closed n-gb closed 1 year ago

n-gb commented 1 year ago

Issue description

I've noticed that 0 0 */2 * 1-5 doesn't work as expected - it seems to ignore the "every second day" cron part

How to reproduce

require 'fugit'
c = Fugit.parse('0 0 */2 * 1-5')
p c.next_time('2022-08-09').to_t.to_datetime.to_s

produces:

"2022-08-10T00:00:00+03:00"

Expected behaviour

"2022-08-11T00:00:00+03:00"

Context

Please replace the content of this section with the output of the following commands:

Darwin MacBook-Pro-Nadia.local 21.6.0 Darwin Kernel Version 21.6.0: Sat Jun 18 17:07:25 PDT 2022; root:xnu-8020.140.41~1/RELEASE_X86_64 x86_64
ruby 3.0.3p157 (2021-11-24 revision 3fb7d2cadc) [x86_64-darwin20]
[:env_tz, nil]
(secs:1661435914.841065,utc~:"2022-08-25 13:58:34.8410649299621582",ltz~:"EEST")
(etz:nil,tnz:"EEST",tziv:"2.0.5",tzidv:nil,rv:"3.0.3",rp:"x86_64-darwin20",win:false,rorv:nil,astz:nil,eov:"1.2.7",eotnz:#<TZInfo::TimezoneProxy: Asia/Amman>,eotnfz:"+0300",eotlzn:"Asia/Amman",eotnfZ:"EEST",debian:nil,centos:nil,osx:"zoneinfo/Europe/Kiev")
[:fugit, "1.5.3"]
[:now, 2022-08-25 17:00:31.504855 +0300, :zone, "EEST"]

Additional context

None

jmettraux commented 1 year ago

Hello,

please read https://github.com/floraison/fugit#the-first-monday-of-the-month

It's counter intuitive, but when both day-of-month and day-of-week are specified, they're ORed, not ANDed. Fugit works correctly.

Kind regards.

n-gb commented 1 year ago

Thank you, @jmettraux !