go to bug id or search bugs for
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.
echo cal_days_in_month(CAL_FRENCH, 13, 14); // Should give 5, not -2380948
Add a Patch
Add a Pull Request
Automatic comment on behalf of cmb
Log: Fix #67976: cal_days_month() fails for final month of the French calendar
> IMHO, this bug should be fixed by removing the end date.
I agree that this should be considered, but I'm uncomfortable to
do so as bugfix. The algorithm we're using claims to have "been
tested for the year 1 to 14", so extending the algorithm might
introduce unforseen issues (in particular, the handling of leap
years comes to mind). Furthermore the French calendar is most
likely not used very often, so if you still wish to extend this
calendar, file a new feature request, please.
Anyhow, thanks for the bug report and for helping us to make PHP