From 58ac3f212f0dca31d8dc3c35ba13c14581d8b5f3 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Mon, 18 Mar 2019 16:51:33 +0000 Subject: Fix Time#advance to work with dates before 1001-03-07 In #10634 the behavior of Time#advance was changed to maintain a proleptic gregorian calendar for dates before calendar reform. However it didn't full address dates a long time before calendar reform and they gradually drift away from the proleptic calendar the further you go back in time. Fix this by always converting the date to gregorian before calling advance which sets the reform date to -infinity. --- activesupport/test/core_ext/time_ext_test.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'activesupport/test/core_ext/time_ext_test.rb') diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb index 7078f3506d..590b81b770 100644 --- a/activesupport/test/core_ext/time_ext_test.rb +++ b/activesupport/test/core_ext/time_ext_test.rb @@ -514,6 +514,8 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase assert_equal Time.local(1582, 10, 15, 15, 15, 10), Time.local(1582, 10, 14, 15, 15, 10).advance(days: 1) assert_equal Time.local(1582, 10, 5, 15, 15, 10), Time.local(1582, 10, 4, 15, 15, 10).advance(days: 1) assert_equal Time.local(1582, 10, 4, 15, 15, 10), Time.local(1582, 10, 5, 15, 15, 10).advance(days: -1) + assert_equal Time.local(999, 10, 4, 15, 15, 10), Time.local(1000, 10, 4, 15, 15, 10).advance(years: -1) + assert_equal Time.local(1000, 10, 4, 15, 15, 10), Time.local(999, 10, 4, 15, 15, 10).advance(years: 1) end def test_last_week -- cgit v1.2.3