diff --git a/lib/fugit/nat.rb b/lib/fugit/nat.rb index abdf74d..07afd95 100644 --- a/lib/fugit/nat.rb +++ b/lib/fugit/nat.rb @@ -691,8 +691,10 @@ def parse_cron(hm, opts) a << tz.data0 if tz a.shift if a.first == [ '0' ] + letters_first = ->(x) { x.is_a?(Numeric) ? x : 0 } + s = a - .collect { |e| e.uniq.sort.collect(&:to_s).join(',') } + .collect { |e| e.uniq.sort_by(&letters_first).collect(&:to_s).join(',') } .join(' ') c = Fugit::Cron.parse(s) diff --git a/spec/nat_spec.rb b/spec/nat_spec.rb index 6caf40f..5e17edb 100644 --- a/spec/nat_spec.rb +++ b/spec/nat_spec.rb @@ -67,6 +67,8 @@ 'every month on the 1st and 2nd at 12:00 pm' => '0 12 1,2 * *', 'every month on the 1st and the 2nd at 12:00 pm' => '0 12 1,2 * *', 'every month on the 1st and the second at 12:00 pm' => '0 12 1,2 * *', + 'every month on the 1st and last at 12:00 pm' => '0 12 L,1 * *', + 'every month on the 1st and the last at 12:00 pm' => '0 12 L,1 * *', # # gh-57, 12pm --> noon