lib/rufus/scheduler/zotime.rb in rufus-scheduler-3.3.0 vs lib/rufus/scheduler/zotime.rb in rufus-scheduler-3.3.1
- old
+ new
@@ -37,11 +37,13 @@
@seconds = s.to_f
@zone = self.class.get_tzone(zone || :current)
fail ArgumentError.new(
- "cannot determine timezone from #{zone.inspect}"
+ "cannot determine timezone from #{zone.inspect}" +
+ " (etz:#{ENV['TZ'].inspect},tnz:#{Time.now.zone.inspect}," +
+ "tzid:#{defined?(TZInfo::Data).inspect})"
) unless @zone
@time = nil # cache for #to_time result
end
@@ -280,10 +282,11 @@
return nil if str == nil
return nil if str == '*'
# ok, it's a timezone then
+ ostr = str
str = Time.now.zone if str == :current || str == :local
# utc_offset
if str.is_a?(Numeric)
@@ -341,9 +344,16 @@
tzi.offset(str, hr * 3600 + mn * 60, 0, str)
tzi.create_timezone
end
) if hr
end
+
+ # last try with ENV['TZ']
+
+ z =
+ (ostr == :local || ostr == :current) &&
+ (::TZInfo::Timezone.get(ENV['TZ']) rescue nil)
+ return z if z
# so it's not a timezone.
nil
end