lib/rufus/scheduler.rb in rufus-scheduler-3.2.2 vs lib/rufus/scheduler.rb in rufus-scheduler-3.3.0
- old
+ new
@@ -23,11 +23,11 @@
#++
require 'date' if RUBY_VERSION < '1.9.0'
require 'time'
require 'thread'
-#require 'tzinfo'
+require 'tzinfo'
module Rufus
class Scheduler
@@ -37,11 +37,11 @@
require 'rufus/scheduler/jobs'
require 'rufus/scheduler/cronline'
require 'rufus/scheduler/job_array'
require 'rufus/scheduler/locks'
- VERSION = '3.2.2'
+ VERSION = '3.3.0'
#
# A common error class for rufus-scheduler
#
class Error < StandardError; end
@@ -152,11 +152,11 @@
alias stop shutdown
def uptime
- @started_at ? Time.now - @started_at : nil
+ @started_at ? Rufus::Scheduler::ZoTime.now - @started_at : nil
end
def uptime_s
self.class.to_duration(uptime)
@@ -476,10 +476,11 @@
stderr.puts(" #{pre} #{l}")
end
stderr.puts(" #{pre} tz:")
stderr.puts(" #{pre} ENV['TZ']: #{ENV['TZ']}")
stderr.puts(" #{pre} Time.now: #{Time.now}")
+ stderr.puts(" #{pre} local_tzone: #{Rufus::Scheduler::ZoTime.local_tzone.inspect}")
stderr.puts(" #{pre} scheduler:")
stderr.puts(" #{pre} object_id: #{object_id}")
stderr.puts(" #{pre} opts:")
stderr.puts(" #{pre} #{@opts.inspect}")
stderr.puts(" #{pre} frequency: #{self.frequency}")
@@ -555,11 +556,11 @@
# work_threads.each { |t| t.raise(KillSignal) }
#end
def start
- @started_at = Time.now
+ @started_at = Rufus::Scheduler::ZoTime.now
@thread =
Thread.new do
while @started_at do
@@ -582,11 +583,11 @@
@jobs.delete_unscheduled
end
def trigger_jobs
- now = Time.now
+ now = Rufus::Scheduler::ZoTime.now
@jobs.each(now) do |job|
job.trigger(now)
end
@@ -601,13 +602,13 @@
ts = t[:rufus_scheduler_time]
next unless job && to && ts
# thread might just have become inactive (job -> nil)
- to = to.is_a?(Time) ? to : ts + to
+ to = ts + to unless to.is_a?(Rufus::Scheduler::ZoTime)
- next if to > Time.now
+ next if to > Rufus::Scheduler::ZoTime.now
t.raise(Rufus::Scheduler::TimeoutError)
end
end
@@ -624,10 +625,10 @@
job_class =
case job_type
when :once
opts[:_t] ||= Rufus::Scheduler.parse(t, opts)
- opts[:_t].is_a?(Time) ? AtJob : InJob
+ opts[:_t].is_a?(Numeric) ? InJob : AtJob
when :every
EveryJob
when :interval
IntervalJob
when :cron