diff --git a/lib/sidetiq/schedule.rb b/lib/sidetiq/schedule.rb index e934bd5..7665a5a 100644 --- a/lib/sidetiq/schedule.rb +++ b/lib/sidetiq/schedule.rb @@ -9,10 +9,12 @@ module Sidetiq # Public: Start time offset from epoch used for calculating run # times in the Sidetiq schedules. - START_TIME = Sidetiq.config.utc ? Time.utc(2010, 1, 1) : Time.local(2010, 1, 1) + def self.start_time + Sidetiq.config.utc ? Time.utc(2010, 1, 1) : Time.local(2010, 1, 1) + end def initialize # :nodoc: - @schedule = IceCube::Schedule.new(START_TIME) + @schedule = IceCube::Schedule.new(self.class.start_time) end def method_missing(meth, *args, &block) # :nodoc: diff --git a/test/test_clock.rb b/test/test_clock.rb index 77fbe9b..640b14f 100644 --- a/test/test_clock.rb +++ b/test/test_clock.rb @@ -19,7 +19,7 @@ class TestClock < Sidetiq::TestCase def test_backfilling BackfillWorker.jobs.clear Sidetiq.stubs(:workers).returns([BackfillWorker]) - start = Sidetiq::Schedule::START_TIME + start = Sidetiq::Schedule.start_time BackfillWorker.stubs(:last_scheduled_occurrence).returns(start.to_f) clock.stubs(:gettime).returns(start) diff --git a/test/test_schedule.rb b/test/test_schedule.rb index 50a2d3a..f687aed 100644 --- a/test/test_schedule.rb +++ b/test/test_schedule.rb @@ -34,5 +34,12 @@ class TestSchedule < Sidetiq::TestCase sched.set_options(backfill: false) refute sched.backfill? end + + def test_use_utc + Sidetiq.config.utc = true + assert_equal(Time.utc(2010, 01, 01), Sidetiq::Schedule.new.start_time) + ensure + Sidetiq.config.utc = false + end end