lib/fugit/cron.rb in fugit-1.1.3 vs lib/fugit/cron.rb in fugit-1.1.4
- old
+ new
@@ -55,11 +55,11 @@
(@minutes || [ '*' ]).join(','),
(@hours || [ '*' ]).join(','),
(@monthdays || [ '*' ]).join(','),
(@months || [ '*' ]).join(','),
(@weekdays || [ [ '*' ] ]).map { |d| d.compact.join('#') }.join(','),
- @timezone ? @timezone.to_s : nil
+ @timezone ? @timezone.name : nil
].compact.join(' ')
end
end
class TimeCursor
@@ -167,23 +167,38 @@
end
def next_time(from=::EtOrbi::EoTime.now)
from = ::EtOrbi.make_time(from)
+ sfrom = from.strftime('%F/%T')
+
t = TimeCursor.new(from.translate(@timezone))
+ #
+ # the translation occurs in the timezone of
+ # this Fugit::Cron instance
loop do
-#p [ :l, Fugit.time_to_s(t.time) ]
+
(from.to_i == t.to_i) && (t.inc(1); next)
month_match?(t) || (t.inc_month; next)
day_match?(t) || (t.inc_day; next)
hour_match?(t) || (t.inc_hour; next)
min_match?(t) || (t.inc_min; next)
sec_match?(t) || (t.inc_sec(@seconds); next)
+
+ st = t.time.strftime('%F/%T')
+ (from, sfrom = t.time, st; next) if st == sfrom
+ #
+ # when transitioning out of DST, this prevents #next_time from
+ # yielding the same literal time twice in a row, see gh-6
+
break
end
t.time.translate(from.zone)
+ #
+ # the answer time is in the same timezone as the `from`
+ # starting point
end
def previous_time(from=::EtOrbi::EoTime.now)
from = ::EtOrbi.make_time(from)