Skip to content

Instantly share code, notes, and snippets.

@exAspArk
Forked from conf/monkey_patches.rb
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save exAspArk/3e9d1dfa5e112b5ebf4e to your computer and use it in GitHub Desktop.
Save exAspArk/3e9d1dfa5e112b5ebf4e to your computer and use it in GitHub Desktop.
Get rid of TZInfo::AmbiguousTime exception
# config/initializers/hacks.rb
Dir[Rails.root.join("lib/hacks/**/*.rb")].each { |file| require file }
# lib/hacks/time_zone.rb
# HACK to not raise TZInfo::AmbiguousTime error (https://github.com/tzinfo/tzinfo/issues/32) on:
# Time.zone.parse('27.10.2014 1:30:00 MSK +03:00') - 1.day
#
# Please get rid of it when you bump rails version and PR below will be resolved:
# https://github.com/rails/rails/pull/17409
module ActiveSupport
class TimeZone
def period_for_local(time, dst = true)
tzinfo.period_for_local(time, dst) { |results| results.first }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment