lib/fugit/cron.rb in fugit-1.4.2 vs lib/fugit/cron.rb in fugit-1.4.3
- old
+ new
@@ -77,14 +77,11 @@
def to_i; @t.to_i; end
%w[ year month day wday hour min sec wday_in_month rweek rday ]
.collect(&:to_sym).each { |k| define_method(k) { @t.send(k) } }
- def inc(i)
- @t = @t + i
- self
- end
+ def inc(i); @t = @t + i; self; end
def dec(i); inc(-i); end
def inc_month
y = @t.year
m = @t.month + 1
@@ -93,10 +90,11 @@
self
end
def inc_day
inc((24 - @t.hour) * 3600 - @t.min * 60 - @t.sec)
+ inc( - @t.hour * 3600) if @t.hour != 0 # compensate for entering DST
end
def inc_hour
inc((60 - @t.min) * 60 - @t.sec)
end
def inc_min
@@ -110,11 +108,11 @@
inc(60 - @t.sec + @cron.seconds.first)
end
end
def dec_month
- dec((@t.day - 1) * 24 * 3600 + @t.hour * 3600 + @t.min * 60 + @t.sec + 1)
+ dec((@t.day - 1) * DAY_S + @t.hour * 3600 + @t.min * 60 + @t.sec + 1)
end
def dec_day
dec(@t.hour * 3600 + @t.min * 60 + @t.sec + 1)
end
@@ -330,11 +328,11 @@
SLOTS = [
[ :seconds, 1, 60 ],
[ :minutes, 60, 60 ],
[ :hours, 3600, 24 ],
- [ :days, 24 * 3600, 365 ] ].freeze
+ [ :days, DAY_S, 365 ] ].freeze
def rough_frequency
slots = SLOTS
.collect { |k, v0, v1|
@@ -372,10 +370,10 @@
@span = span
@delta_min = deltas.min; @delta_max = deltas.max
@occurrences = deltas.size
- @span_years = span / (365 * 24 * 3600)
+ @span_years = span / YEAR_S
@yearly_occurrences = @occurrences.to_f / @span_years
end
def to_debug_s