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' }
Written by Lev Lukomsky
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#