aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/time_with_zone.rb
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2014-01-31 17:13:12 +0000
committerAndrew White <andyw@pixeltrix.co.uk>2014-01-31 17:13:12 +0000
commit63f8fabe4939ad59d597dfea441002ef5b16d2f4 (patch)
tree3f4cd24e7c9d24649338396df1c67902d5a66037 /activesupport/lib/active_support/time_with_zone.rb
parentf484df79f26bca7e952f907878074eddbf72656d (diff)
downloadrails-63f8fabe4939ad59d597dfea441002ef5b16d2f4.tar.gz
rails-63f8fabe4939ad59d597dfea441002ef5b16d2f4.tar.bz2
rails-63f8fabe4939ad59d597dfea441002ef5b16d2f4.zip
Maintain the current timezone in wrap_with_time_zone
Extend the solution from the fix for #12163 to the general case where `Time` methods are wrapped with a time zone. Fixes #12596.
Diffstat (limited to 'activesupport/lib/active_support/time_with_zone.rb')
-rw-r--r--activesupport/lib/active_support/time_with_zone.rb9
1 files changed, 2 insertions, 7 deletions
diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb
index d459af1778..c25c97cfa8 100644
--- a/activesupport/lib/active_support/time_with_zone.rb
+++ b/activesupport/lib/active_support/time_with_zone.rb
@@ -292,12 +292,6 @@ module ActiveSupport
end
end
- def change(options)
- new_time = time.change(options)
- periods = time_zone.periods_for_local(new_time)
- self.class.new(nil, time_zone, new_time, periods.include?(period) ? period : nil)
- end
-
%w(year mon month day mday wday yday hour min sec usec nsec to_date).each do |method_name|
class_eval <<-EOV, __FILE__, __LINE__ + 1
def #{method_name} # def month
@@ -396,7 +390,8 @@ module ActiveSupport
def wrap_with_time_zone(time)
if time.acts_like?(:time)
- self.class.new(nil, time_zone, time)
+ periods = time_zone.periods_for_local(time)
+ self.class.new(nil, time_zone, time, periods.include?(period) ? period : nil)
elsif time.is_a?(Range)
wrap_with_time_zone(time.begin)..wrap_with_time_zone(time.end)
else