diff options
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/attribute_methods.rb | 4 | ||||
-rwxr-xr-x | activerecord/test/cases/attribute_methods_test.rb | 2 |
3 files changed, 5 insertions, 3 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 645ecdcda6..a1c9a0f4d7 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Time zone aware attributes use Time#in_time_zone [Geoff Buesing] + * Fixed that scoped joins would not always be respected #6821 [Theory/Danger] * Ensure that ActiveRecord::Calculations disambiguates field names with the table name. #11027 [cavalle] diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb index f976e70a06..46ecfc1969 100644 --- a/activerecord/lib/active_record/attribute_methods.rb +++ b/activerecord/lib/active_record/attribute_methods.rb @@ -161,7 +161,7 @@ module ActiveRecord cached = @attributes_cache['#{attr_name}'] return cached if cached && !reload time = read_attribute('#{attr_name}') - @attributes_cache['#{attr_name}'] = time.acts_like?(:time) ? time.in_current_time_zone : time + @attributes_cache['#{attr_name}'] = time.acts_like?(:time) ? time.in_time_zone : time end EOV evaluate_attribute_method attr_name, method_body @@ -181,7 +181,7 @@ module ActiveRecord def #{attr_name}=(time) if time time = time.to_time rescue time unless time.acts_like?(:time) - time = time.in_current_time_zone if time.acts_like?(:time) + time = time.in_time_zone if time.acts_like?(:time) end write_attribute(:#{attr_name}, time) end diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb index b42d419216..376a70d6fe 100755 --- a/activerecord/test/cases/attribute_methods_test.rb +++ b/activerecord/test/cases/attribute_methods_test.rb @@ -178,7 +178,7 @@ class AttributeMethodsTest < ActiveRecord::TestCase utc_time = Time.utc(2008, 1, 1) in_time_zone "Pacific Time (US & Canada)" do record = @target.new - record.written_on = utc_time.in_current_time_zone + record.written_on = utc_time.in_time_zone assert_equal utc_time, record.written_on assert_equal TimeZone["Pacific Time (US & Canada)"], record.written_on.time_zone assert_equal Time.utc(2007, 12, 31, 16), record.written_on.time |