I am using delayed_job in my rails application. i want to run a delayed_job based on a table column which is saved in UTC. My server setting is in EST. Delayed job will take UTC or EST?
If you are using active_record_delayed_job then your application time zone as set in application.rb will be used.
Following is taken from delayed_job source (https://github.com/collectiveidea/delayed_job_active_record/blob/master/lib/delayed/backend/active_record.rb#L97)
# Get the current time (GMT or local depending on DB)
# Note: This does not ping the DB to get the time, so all your clients
# must have syncronized clocks.
def self.db_time_now
if Time.zone
Time.zone.now
elsif ::ActiveRecord::Base.default_timezone == :utc
Time.now.utc
else
Time.now
end
end
and this is used in reserve_with_scope which queries the DB for available jobs (starting in line 56)
If you are not sure which timezone is set in your application, you can use the following from the rails console
2.1.4 :005 > Rails.application.config.time_zone
=> "Helsinki"
or
2.1.4 :007 > Time.zone.name
=> "Helsinki"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With