From: duerst Date: 2022-07-29T07:03:48+00:00 Subject: [ruby-dev:51186] [Ruby master Bug#18946] Time#to_date returns incorrect date Issue #18946 has been updated by duerst (Martin Dürst). This may be due to the Gregorian calendar reform (see https://en.wikipedia.org/wiki/Gregorian_calendar#Gregorian_reform, which says: "Julian Thursday, 4 October 1582, being followed by Gregorian Friday, 15 October"). Time seems to use a proleptic Gregorian calendar (the Gregorian calendar extended to before the Gregorian reform, see https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar) while Date seems to be using the Julian calendar before the 'official' reform date. Please note that the reform didn't get applied at that date everywhere; different parts of the globe changed at different times, and some churches still use the old calendar. ``` Time.local(1582,10,14).to_date => # Time.local(1582,10,15).to_date => # ``` Also, please compare: ``` Time.local(1500,3,1).to_date => # Time.local(1500,2,29).to_date => # ``` (in Time, there's no February 29 in 1500, because it's proleptic) with ``` Time.local(1500,3,9).to_date => # Time.local(1500,3,10).to_date => # Time.local(1500,3,11).to_date => # ``` In Date, there is a February 29 in 1500, because it's Julian. See also `ri Date`. It may be a good idea to add a note to the documentation for Time, to say that it uses the proleptic Gregorian calendar, and this is different from Date. Please note that dates are *relatively* easy if the date is close to the present, but the farther you move out, the more complicated it may get. ---------------------------------------- Bug #18946: Time#to_date returns incorrect date https://bugs.ruby-lang.org/issues/18946#change-98504 * Author: kei-p (Keisuke Ishizawa) * Status: Open * Priority: Normal * ruby -v: 3.1.2 * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- Time#to_date returns incorrect date. Actual Behavior: ``` Time.local(1499, 12, 27).to_date => # ``` Expected Behavior: ``` Time.local(1499, 12, 27).to_date => # ``` -- https://bugs.ruby-lang.org/