diff options
author | Geoff Buesing <gbuesing@gmail.com> | 2008-03-17 05:50:13 +0000 |
---|---|---|
committer | Geoff Buesing <gbuesing@gmail.com> | 2008-03-17 05:50:13 +0000 |
commit | 54ccdd334385fea706eb8d5b3ed95d7102a9d0d4 (patch) | |
tree | 6e2a492c31911cefad337f732132fd41285bda5b /activerecord | |
parent | fe7c68ee5d4d78b705bc91c0652b05202b3eb30e (diff) | |
download | rails-54ccdd334385fea706eb8d5b3ed95d7102a9d0d4.tar.gz rails-54ccdd334385fea706eb8d5b3ed95d7102a9d0d4.tar.bz2 rails-54ccdd334385fea706eb8d5b3ed95d7102a9d0d4.zip |
Time, DateTime and TimeWithZone #in_time_zone defaults to Time.zone. Removing now unneeded #in_current_time_zone. ActiveRecord time zone aware attributes updated to use #in_time_zone
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9047 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
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 |