diff options
author | Alexey Shein <alexey.shein.dev@gmail.com> | 2016-04-21 03:53:48 +0500 |
---|---|---|
committer | Jeremy Daer <jeremydaer@gmail.com> | 2016-04-25 20:55:33 -0500 |
commit | 420730b10b46be7e40d806007bb28d3b17c7519f (patch) | |
tree | 66503d58e8084581f27494c9a536960276effc4f /activesupport/lib/active_support | |
parent | ea628f72c3f6ef77752794356fcb358858fd8827 (diff) | |
download | rails-420730b10b46be7e40d806007bb28d3b17c7519f.tar.gz rails-420730b10b46be7e40d806007bb28d3b17c7519f.tar.bz2 rails-420730b10b46be7e40d806007bb28d3b17c7519f.zip |
Do not cache ActiveSupport::TimeZone#utc_offset
This can be an issue when TZInfo::TimeZone#current_period is refreshed
due to timezone period transition, but it's not reflected in
ActiveSupport::TimeZone object.
For example, on Sun, 26 Oct 2014 22:00 UTC, Moscow changed its TZ from
MSK +04:00 to MSK +03:00 (-1 hour). If ActiveSupport::TimeZone['Moscow']
happens to be initialized just before the timezone transition, it will
cache its stale utc_offset even after the timezone transition.
This commit removes cache and fixes this issue.
Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/values/time_zone.rb | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb index 00fdb22c31..19420cee5e 100644 --- a/activesupport/lib/active_support/values/time_zone.rb +++ b/activesupport/lib/active_support/values/time_zone.rb @@ -278,7 +278,6 @@ module ActiveSupport @name = name @utc_offset = utc_offset @tzinfo = tzinfo || TimeZone.find_tzinfo(name) - @current_period = nil end # Returns the offset of this time zone from UTC in seconds. @@ -286,8 +285,7 @@ module ActiveSupport if @utc_offset @utc_offset else - @current_period ||= tzinfo.current_period if tzinfo - @current_period.utc_offset if @current_period + tzinfo.current_period.utc_offset if tzinfo && tzinfo.current_period end end |