cal_days_month() fails for final month of the French calendar
| Bug #67976 | cal_days_month() fails for final month of the French calendar | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2014-09-08 10:04 UTC | Modified: | 2016-07-28 17:38 UTC |
|
||||||
| From: | fisharebest at gmail dot com | Assigned: | cmb (profile) | |||||||
| Status: | Closed | Package: | Calendar related | |||||||
| PHP Version: | 5.6.0 | OS: | All | |||||||
| Private report: | No | CVE-ID: | None | |||||||
[2014-09-08 10:04 UTC] fisharebest at gmail dot com
Description: ------------ PHP calendar functions support the French Republican calendar. Most calendars (Jewish, Gregorian, Julian) start at 0001-01-01 and run forwards until the end of time. However, PHP implements an end date for the French calendar. Hence dates in year 15 onwards are invalid. In other words, it starts at 0001-01-01 and ends at 0014-13-05. The algorithm for calculating the number of days in each month (ext/calendar/calendar.c#363) can be summarised as: (Julian day of the first day of the next month) minus (Julian day of the first day of this month) For example, the number of days in December 2014 is given by JD(2015-01-01) - JD(2014-12-01). Now, when calculating the number of days of finl month of the final year of the French calendar, PHP attempts to calculate JD(0015-01-01) - JD(0014-13-01) Since the first date is invalid (JD=0), this returns a nonsensical answer. This bug applies to all versions of PHP - see http://3v4l.org/2vhM7 IMHO, this bug should be fixed by removing the end date. The French calendar is still used today, though rarely and in limited contexts. Test script: --------------- echo cal_days_in_month(CAL_FRENCH, 13, 14); // Should give 5, not -2380948
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2016-07-28 17:37 UTC] cmb@php.net
-Status: Open +Status: Closed
[2016-07-28 17:38 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
[2016-07-28 17:38 UTC] cmb@php.net