Skip to content

Commit

Permalink
Fix week converion issue in cron syntax. (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
nozayasu authored Jan 27, 2024
1 parent 5b57ee6 commit abe86cc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/elastic_whenever/schedule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def schedule_expression(frequency, options)
day.gsub!("*", "?") if week != "?"
# cron syntax: sunday -> 0
# scheduled expression: sunday -> 1
week.gsub!(/(\d)/) { (Integer($1) + 1) % 7 }
week.gsub!(/(\d)/) { Integer($1) + 1 }
year = year || "*"
"cron(#{min} #{hour} #{day} #{mon} #{week} #{year})"
# schedule expression syntax
Expand Down
2 changes: 1 addition & 1 deletion spec/schedule_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@
end

it "converts from cron syntax specified week" do
expect(schedule.schedule_expression("0 0 * * 0", {})).to eq "cron(0 0 ? * 1 *)"
expect(schedule.schedule_expression("0 0 * * 0,1,2,3,4,5,6", {})).to eq "cron(0 0 ? * 1,2,3,4,5,6,7 *)"
end

it "converts from day shortcuts" do
Expand Down

0 comments on commit abe86cc

Please sign in to comment.