aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2013-01-22 14:24:42 +0000
committerAndrew White <andyw@pixeltrix.co.uk>2013-01-22 14:24:42 +0000
commit97a4db91d69d1795fe9079027968f0c0453bd0a1 (patch)
tree8f40966567f78765377d80613ce2ded7e167fed7 /activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb
parent7ee76714abe4775db4bc44b052338e732d38e93b (diff)
downloadrails-97a4db91d69d1795fe9079027968f0c0453bd0a1.tar.gz
rails-97a4db91d69d1795fe9079027968f0c0453bd0a1.tar.bz2
rails-97a4db91d69d1795fe9079027968f0c0453bd0a1.zip
Revert "Merge pull request #6986 from kennyj/fix_6975"
This reverts commit 8905c1fb496641c3cdb7b3b816ae6d3d4b2c2b73. Closes #8460 Conflicts: activerecord/test/cases/dirty_test.rb
Diffstat (limited to 'activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb')
-rw-r--r--activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb19
1 files changed, 5 insertions, 14 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb b/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb
index 39d81cf6ef..45810322de 100644
--- a/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb
+++ b/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb
@@ -42,14 +42,11 @@ module ActiveRecord
unless time.acts_like?(:time)
time = time.is_a?(String) ? Time.zone.parse(time) : time.to_time rescue time
end
- zoned_time = time && time.in_time_zone rescue nil
- rounded_time = round_usec(zoned_time)
- rounded_value = round_usec(read_attribute("#{attr_name}"))
- if (rounded_value != rounded_time) || (!rounded_value && original_time)
- write_attribute("#{attr_name}", original_time)
- #{attr_name}_will_change!
- @attributes_cache["#{attr_name}"] = zoned_time
- end
+ time = time.in_time_zone rescue nil if time
+ changed = read_attribute(:#{attr_name}) != time
+ write_attribute(:#{attr_name}, original_time)
+ #{attr_name}_will_change! if changed
+ @attributes_cache["#{attr_name}"] = time
end
EOV
generated_attribute_methods.module_eval(method_body, __FILE__, line)
@@ -63,12 +60,6 @@ module ActiveRecord
time_zone_aware_attributes && !self.skip_time_zone_conversion_for_attributes.include?(name.to_sym) && column.type.in?([:datetime, :timestamp])
end
end
-
- private
- def round_usec(value)
- return unless value
- value.change(:usec => 0)
- end
end
end
end