Commit 7ef60823 authored by Tim Smith's avatar Tim Smith Committed by GitHub
Browse files

Merge pull request #93 from evertrue/evertrue/eherot/fix_numeric_dates

Fix handling of numeric weekdays (Fixes #74)
parents 8034ed66 b377b36c
......@@ -18,7 +18,7 @@ class Cron
def self.validate_numeric(spec, min, max)
return true if spec == '*'
# binding.pry
if spec.is_a? Integer
if spec.respond_to? :to_int
return false unless spec >= min && spec <= max
return true
end
......@@ -35,9 +35,9 @@ class Cron
def self.validate_month(spec)
return true if spec == '*'
if spec.class == Integer
if spec.respond_to? :to_int
validate_numeric(spec, 1, 12)
elsif spec.class == String
elsif spec.respond_to? :to_str
return true if spec == '*'
# Named abbreviations are permitted but not as part of a range or with stepping
return true if %w(jan feb mar apr may jun jul aug sep oct nov dec).include? spec.downcase
......@@ -50,9 +50,9 @@ class Cron
def self.validate_dow(spec)
return true if spec == '*'
if spec.class == Integer
if spec.respond_to? :to_int
validate_numeric(spec, 0, 7)
elsif spec.class == String
elsif spec.respond_to? :to_str
return true if spec == '*'
# Named abbreviations are permitted but not as part of a range or with stepping
return true if %w(sun mon tue wed thu fri sat).include? spec.downcase
......
......@@ -64,6 +64,15 @@ cron_d 'fixnum-job' do
action :create
end
cron_d 'fixnum-weekdayjob' do
minute 0
hour 1
weekday 2
command '/bin/true'
user 'appuser'
action :create
end
cron_d 'predefined_value_check' do
predefined_value '@midnight'
command '/bin/true'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment