lib/rufus/scheduler/cronline.rb in rufus-scheduler-3.0.7 vs lib/rufus/scheduler/cronline.rb in rufus-scheduler-3.0.8
- old
+ new
@@ -147,10 +147,14 @@
break
end
global_time(time, from.utc?)
+
+ rescue TZInfo::PeriodNotFound
+
+ next_time(from + 3600)
end
# Returns the previous time the cronline matched. It's like next_time, but
# for the past.
#
@@ -178,10 +182,14 @@
break
end
global_time(time, from.utc?)
+
+ rescue TZInfo::PeriodNotFound
+
+ previous_time(time)
end
# Returns an array of 6 arrays (seconds, minutes, hours, days,
# months, weekdays).
# This method is used by the cronline unit tests.
@@ -427,22 +435,30 @@
[ "#{WEEKDAYS[date.wday]}##{pos}", "#{WEEKDAYS[date.wday]}##{neg}" ]
end
def local_time(time)
- time = @timezone ? @timezone.utc_to_local(time.getutc) : time
+
+ @timezone ? @timezone.utc_to_local(time.getutc) : time
end
def global_time(time, from_in_utc)
+
if @timezone
- time = @timezone.local_to_utc(time)
+ time =
+ begin
+ @timezone.local_to_utc(time)
+ rescue TZInfo::AmbiguousTime
+ @timezone.local_to_utc(time, time.isdst)
+ end
time = time.getlocal unless from_in_utc
end
time
end
def round_to_seconds(time)
+
# Ruby 1.8 doesn't have #round
time.respond_to?(:round) ? time.round : time - time.usec * 1e-6
end
end
end