Skip to content

Commit

Permalink
Change how cron deals with modulo and offset gh-76
Browse files Browse the repository at this point in the history
  • Loading branch information
jmettraux committed Sep 14, 2022
1 parent 3242ea6 commit 6bf1686
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

## fugit 1.7.0 not yet released

* Change how cron deals with modulo and offset, gh-76
* Be liberal with extra commas, gh-77


Expand Down
2 changes: 1 addition & 1 deletion lib/fugit/cron.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def weekday_hash_match?(nt, hsh)

def weekday_modulo_match?(nt, mod)

(nt.rweek + mod[1]) % mod[0] == 0
(nt.rweek % mod[0]) == (mod[1] % mod[0])
end

def weekday_match?(nt)
Expand Down
10 changes: 7 additions & 3 deletions spec/cron_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -766,10 +766,14 @@ class Fugit::Cron::TimeCursor
Fugit::Cron.do_parse('30 14 * * 4%4+3 Australia/Melbourne')
.next_time(t0)

expect(nt.to_s).to eq('2022-10-06 03:30:00 Z') # post gh-47
#
#expect(nt.to_s).to eq(/^2022-10-06 03:30:00 (Z|\+0000)$/)
# post gh-47
expect(nt.to_s).to match(/^2022-09-22 04:30:00 (Z|\+0000)$/)
# post gh-76

in_zone('Australia/Melbourne') do
expect(nt.to_t.to_s).to eq('2022-10-06 14:30:00 +1100')
#expect(nt.to_t.to_s).to eq('2022-10-06 14:30:00 +1100') # post gh-47
expect(nt.to_t.to_s).to eq('2022-09-22 14:30:00 +1000') # post gh-76
end
end
end
Expand Down

0 comments on commit 6bf1686

Please sign in to comment.