Skip to content

Commit

Permalink
Go with 1,L for 1st and last, gh-88
Browse files Browse the repository at this point in the history
  • Loading branch information
jmettraux committed Sep 29, 2023
1 parent 0a34a0c commit 30ce5c5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/fugit/nat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -691,10 +691,11 @@ 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 }
letters_last = lambda { |x| x.is_a?(Numeric) ? x : 999_999 }

s = a
.collect { |e| e.uniq.sort_by(&letters_first).collect(&:to_s).join(',') }
.collect { |e|
e.uniq.sort_by(&letters_last).collect(&:to_s).join(',') }
.join(' ')

c = Fugit::Cron.parse(s)
Expand Down
4 changes: 2 additions & 2 deletions spec/nat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +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 * *',
'every month on the 1st and last at 12:00 pm' => '0 12 1,L * *',
'every month on the 1st and the last at 12:00 pm' => '0 12 1,L * *',
#
# gh-57, 12pm --> noon

Expand Down

0 comments on commit 30ce5c5

Please sign in to comment.