From 224d82ee5990b101b7a44c37bed026b602bd4f20 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Tue, 11 Dec 2012 07:06:34 +0000 Subject: Deprecate Date#to_time_in_current_zone The to_time_in_current_zone method doesn't match the naming of the methods for converting to ActiveSupport::TimeWithZone on Time and DateTime. Since DateTime inherits from Date that has led to confusion with some users using the to_time_in_current_zone method with DateTime instances and having the time part dropped and the UTC offset lost. This commit fixes this by deprecating the old method and adding a new in_time_zone method which matches the naming for DateTime and Time. This should prevent accidently dropping times and UTC offsets when converting DateTime instances to ActiveSupport::TimeWithZone. --- activesupport/test/core_ext/date_ext_test.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'activesupport/test') diff --git a/activesupport/test/core_ext/date_ext_test.rb b/activesupport/test/core_ext/date_ext_test.rb index 7ae1f67785..278ee96796 100644 --- a/activesupport/test/core_ext/date_ext_test.rb +++ b/activesupport/test/core_ext/date_ext_test.rb @@ -354,3 +354,11 @@ class DateExtBehaviorTest < ActiveSupport::TestCase end end end + +class DateExtConversionsTest < ActiveSupport::TestCase + def test_to_time_in_current_zone_is_deprecated + assert_deprecated(/to_time_in_current_zone/) do + Date.new(2012,6,7).to_time_in_current_zone + end + end +end -- cgit v1.2.3