aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorKristopher Murata <kris@kside.net>2010-04-08 03:39:46 -0400
committerJeremy Kemper <jeremy@bitsweat.net>2010-04-08 10:26:16 -0700
commit36129f21b86db4bd69e932e586129e246c2a5ca8 (patch)
treef65bf7e2f8e16607ebd16d97c23e7bfd6b3a7c4e /activerecord/lib
parentab5aa55cb86424286f65b273105a3602bbd77258 (diff)
downloadrails-36129f21b86db4bd69e932e586129e246c2a5ca8.tar.gz
rails-36129f21b86db4bd69e932e586129e246c2a5ca8.tar.bz2
rails-36129f21b86db4bd69e932e586129e246c2a5ca8.zip
Dirty datetime attributes should be aware of time zone info [#3658 state:resolved]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/attribute_methods/dirty.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/dirty.rb b/activerecord/lib/active_record/attribute_methods/dirty.rb
index 435aea9b09..36f2a9777c 100644
--- a/activerecord/lib/active_record/attribute_methods/dirty.rb
+++ b/activerecord/lib/active_record/attribute_methods/dirty.rb
@@ -52,6 +52,8 @@ module ActiveRecord
@changed_attributes.delete(attr) unless field_changed?(attr, old, value)
else
old = clone_attribute_value(:read_attribute, attr)
+ # Save Time objects as TimeWithZone if time_zone_aware_attributes == true
+ old = old.in_time_zone if clone_with_time_zone_conversion_attribute?(attr, old)
@changed_attributes[attr] = old if field_changed?(attr, old, value)
end
@@ -84,6 +86,10 @@ module ActiveRecord
old != value
end
+
+ def clone_with_time_zone_conversion_attribute?(attr, old)
+ old.class.name == "Time" && time_zone_aware_attributes && !skip_time_zone_conversion_for_attributes.include?(attr.to_sym)
+ end
end
end
end