From abe86cc8a144e9c49d5584ae9f3d62849f405ffc Mon Sep 17 00:00:00 2001 From: nozayasu <84norin@gmail.com> Date: Sat, 27 Jan 2024 21:18:34 +0900 Subject: [PATCH] Fix week converion issue in cron syntax. (#70) --- lib/elastic_whenever/schedule.rb | 2 +- spec/schedule_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/elastic_whenever/schedule.rb b/lib/elastic_whenever/schedule.rb index 9fd0837..34c957e 100644 --- a/lib/elastic_whenever/schedule.rb +++ b/lib/elastic_whenever/schedule.rb @@ -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 diff --git a/spec/schedule_spec.rb b/spec/schedule_spec.rb index 18dc34c..8250666 100644 --- a/spec/schedule_spec.rb +++ b/spec/schedule_spec.rb @@ -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