Rails, how to get 1.day.from_now at a set time (morning)?

delayed-job, ruby, ruby-on-rails, ruby-on-rails-3

Solution

If your rails server is not running in PST/PDT:

Time.use_zone("Pacific Time (US & Canada)") { 1.day.from_now.beginning_of_day + 9.5.hours }

If it is already running in PST/PDT, you can shorten it to:

1.day.from_now.beginning_of_day + 9.5.hours

Have a look at Time and TimeZone for more info.

Problem

I currently queue my DelayedJob like so: ``` Delayed::Job.enqueue MyJob.new, 5, 1.day.from_now ``` I'm looking for a way to set a different execution time: ``` Tomorrow morning at 9:30am PST ``` Does Rails have a helper that can take care of this? Thanks

Original source