tomykaira/clockwork — pull request #36 by barelyknown (2013-05-25 15:55:46+00:00)
Title: make t an ActiveSupport::TimeWithZone instance

`t` that is being passed to `:if` was being converted to local time using the `utc_to_local` method from `TZInfo`.

From the `TZInfo` docs:

> Note that the Time returned will look like it is UTC (Time.zone will return "UTC"). This is because it is not currently possible to change the offset of an individual Time instance.

Since it looks like the time zone is UTC, comparisons within the `:if` lambda don't work as expected. I added the following test that fails without this patch.

test ":if it is compared to a time with zone" do
tz = "America/Chicago"
time = Time.utc(2012,5,25,10,00)
Clockwork.every(1.second, 'myjob', tz: tz, :if => lambda { |t|(
((time - 1.hour)..(time + 1.hour)).cover? t
)})
assert_will_run time
end

I changed the `convert_timezone` method to use the `in_time_zone` method from `ActiveSupport::TimeWithZone`. That fixes the issue without breaking anything.