aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/values/time_zone.rb
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2014-01-26 16:56:33 +0000
committerAndrew White <andyw@pixeltrix.co.uk>2014-01-26 16:56:33 +0000
commitb5944928700cfc13ed8f615acb54116a3039f345 (patch)
treea4b167f1c0b2064f4fe02291e6d03b96a9ba291a /activesupport/lib/active_support/values/time_zone.rb
parent718d3b0bc53bb5da4e5fc32d1a27f2119e6c747c (diff)
downloadrails-b5944928700cfc13ed8f615acb54116a3039f345.tar.gz
rails-b5944928700cfc13ed8f615acb54116a3039f345.tar.bz2
rails-b5944928700cfc13ed8f615acb54116a3039f345.zip
Maintain current timezone when changing time during DST overlap
Currently if a time is changed during DST overlap in the autumn then the method `period_for_local` will return the DST period. However if the original time is not DST then this can be surprising and is not what is generally wanted. This commit changes that behavior to maintain the current period if it's in the list of periods returned by `periods_for_local`. It is possible to alter the behavior of `period_for_local` by specifying a second argument but since we may be change from another time that could be either DST or not then this would give inconsistent results. Fixes #12163.
Diffstat (limited to 'activesupport/lib/active_support/values/time_zone.rb')
-rw-r--r--activesupport/lib/active_support/values/time_zone.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb
index beaac42fa1..eb785d46ce 100644
--- a/activesupport/lib/active_support/values/time_zone.rb
+++ b/activesupport/lib/active_support/values/time_zone.rb
@@ -352,6 +352,10 @@ module ActiveSupport
tzinfo.period_for_local(time, dst)
end
+ def periods_for_local(time) #:nodoc:
+ tzinfo.periods_for_local(time)
+ end
+
def self.find_tzinfo(name)
TZInfo::TimezoneProxy.new(MAPPING[name] || name)
end