Last Updated: May 05, 2016
·
1.402K
· Лев Лукомський

Local Timezone Fix for Whenever Gem

Whenever gem uses only UTC time to schedule tasks. But I like to think about scheduling in my Local Time. So I made this little helper method:

# config/schedule.rb
require 'time'

# see: https://github.com/javan/whenever/pull/239
# time should be > 03:00
def kyiv_time(time)
  TZInfo::Timezone.get('Europe/Kiev').local_to_utc(Time.parse(time))
end

every(1.day, at: kyiv_time('05:00')) { rake 'server_db:backup' }