Skip to content

Commit

Permalink
Ensure @Yearly and friends accept a timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
jmettraux committed Oct 3, 2024
1 parent ea056f0 commit 11790c3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/fugit/cron.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,23 @@ def new(original)
def parse(s)

return s if s.is_a?(self)
return nil unless s.is_a?(String)

s = SPECIALS[s] || s
s0 = s
s = s.strip

return nil unless s.is_a?(String)
s =
if s[0, 1] == '@'
ss = s.split(/\s+/, 2)
[ SPECIALS[ss[0]] || ss, *ss[1..-1] ].join(' ')
else
s
end

#p s; Raabro.pp(Parser.parse(s, debug: 3), colors: true)
h = Parser.parse(s.strip)
h = Parser.parse(s)

self.allocate.send(:init, s, h)
self.allocate.send(:init, s0, h)
end

def do_parse(s)
Expand Down
3 changes: 3 additions & 0 deletions spec/cron_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,9 @@ class Fugit::Cron::TimeCursor
[ '@noon', '0 12 * * *' ],
[ '@hourly', '0 * * * *' ],

[ '@yearly Asia/Kuala_Lumpur', '0 0 1 1 * Asia/Kuala_Lumpur' ],
[ '@noon Asia/Jakarta', '0 12 * * * Asia/Jakarta' ],

# min hou dom mon dow

[ '5 0 * * *', '5 0 * * *' ],
Expand Down

0 comments on commit 11790c3

Please sign in to comment.