lib/rufus/scheduler/zotime.rb in rufus-scheduler-3.3.2 vs lib/rufus/scheduler/zotime.rb in rufus-scheduler-3.3.3
- old
+ new
@@ -191,10 +191,15 @@
off = off >= 0 ? "+#{off}" : off.to_s
strftime('%H%M') + off + utc.strftime('(%H%M)')
end
+ def to_time_s
+
+ strftime("%H:%M:%S.#{'%06d' % usec}")
+ end
+
def self.now(zone=nil)
ZoTime.new(Time.now.to_f, zone)
end
@@ -280,14 +285,23 @@
# discard quickly when it's certainly not a timezone
return nil if str == nil
return nil if str == '*'
+ ostr = str
+ str = :current if str == :local
+
+ # use Rails' zone by default if Rails is present
+
+ return Time.zone.tzinfo if (
+ ENV['TZ'].nil? && str == :current &&
+ Time.respond_to?(:zone) && Time.zone.respond_to?(:tzinfo)
+ )
+
# ok, it's a timezone then
- ostr = str
- str = ENV['TZ'] || Time.now.zone if str == :current || str == :local
+ str = ENV['TZ'] || Time.now.zone if str == :current
# utc_offset
if str.is_a?(Numeric)
i = str.to_i
@@ -361,12 +375,10 @@
) if hr
end
# last try with ENV['TZ']
- z =
- (ostr == :local || ostr == :current) &&
- (::TZInfo::Timezone.get(ENV['TZ']) rescue nil)
+ z = ostr == :current && (::TZInfo::Timezone.get(ENV['TZ']) rescue nil)
return z if z
# so it's not a timezone.
nil