Closed lstrzebinczyk closed 2 years ago
Fugit.parse("0 13 * * wed").to_cron_s
# => "0 13 * * 3"
Fugit.parse("0 13 * * wed%2").to_cron_s
# => "0 13 * * 3#2#0"
Thanks for reporting that. I will fix it.
I will make sure Fugit::Cron#to_cron_s
is correct for other uses of %
and of #
, eventually fix, and then release 1.5.3.
Nota bene:
Fugit.parse("0 13 * * 3#2#0")
# => => #<EtOrbi::EoTime:0x000009991c9cc9d0 ...>
Fugit::Cron.do_parse("0 13 * * 3#2#0")
# => ArgumentError (invalid cron string "0 13 * * 3#2#0")
Fugit.parse
should reject "0 13 * * 3#2#0"
and return nil
. Fugit.do_parse
should raise an error.
Closing. Thanks again for reporting. I will work on gh-69 and then release 1.5.3 with the fix for your issue. If there is anything else here, feel free to comment.
fugit 1.5.3 out https://rubygems.org/gems/fugit/versions/1.5.3
Thanks!
irb(main):001:0> Fugit.parse(Fugit.parse("0 13 * * *").to_cron_s)
=> #<Fugit::Cron:0x00005630fc4ed4b8 @cron_s=nil, @hours=[13], @minutes=[0], @monthdays=nil, @months=nil, @original="0 13 * * *", @seconds=[0], @timezone=nil, @weekdays=nil, @zone=nil>
irb(main):002:0> Fugit.parse(Fugit.parse("0 13 * * wed%2").to_cron_s)
=> #<Fugit::Cron:0x00005630fc69fe28 @cron_s=nil, @hours=[13], @minutes=[0], @monthdays=nil, @months=nil, @original="0 13 * * 3%2", @seconds=[0], @timezone=nil, @weekdays=[[3, [2, 0]]], @zone=nil>
For a quick check, it seems to work! Awesome work, and a quick response. Thank you very much!
You're welcome!
Issue description
My team is creating a bot, which allows people to schedule something with a cron-like string to indicate time interval. We have a bug report which seem to boil down to inconsistency with how fugit deals with strings including a % syntax.
How to reproduce
The simplest piece of code that reproduces the issue, for example:
Expected behaviour
My understanding is, that these 2 cases should behave the same, and return
Fugit::Cron
instance.Context