lib/fugit/cron.rb in fugit-1.3.3 vs lib/fugit/cron.rb in fugit-1.3.4
- old
+ new
@@ -186,10 +186,21 @@
def day_match?(nt)
return weekday_match?(nt) || monthday_match?(nt) \
if @weekdays && @monthdays
+ #
+ # From `man 5 crontab`
+ #
+ # Note: The day of a command's execution can be specified
+ # by two fields -- day of month, and day of week.
+ # If both fields are restricted (ie, are not *), the command will be
+ # run when either field matches the current time.
+ # For example, ``30 4 1,15 * 5'' would cause a command to be run
+ # at 4:30 am on the 1st and 15th of each month, plus every Friday.
+ #
+ # as seen in gh-5 and gh-35
return false unless weekday_match?(nt)
return false unless monthday_match?(nt)
true
@@ -334,9 +345,10 @@
slots.each do |k, v0, v1, a|
next unless a && a.length > 1
return (a + [ a.first + v1 ])
.each_cons(2)
.collect { |a0, a1| a1 - a0 }
+ .select { |d| d > 0 } # weed out zero deltas
.min * v0
end
slots.reverse.each do |k, v0, v1, a|
return v0 * v1 if a && a.length == 1