Bug #67976 [Opn->Csd]: cal_days_month() fails for final month of the French calendar

From: Date: Thu, 28 Jul 2016 17:37:27 +0000
Subject: Bug #67976 [Opn->Csd]: cal_days_month() fails for final month of the French calendar
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-202680@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67976&edit=1 ID: 67976 Updated by: cmb@php.net Reported by: fisharebest at gmail dot com Summary: cal_days_month() fails for final month of the French calendar -Status: Open +Status: Closed Type: Bug Package: Calendar related Operating System: All PHP Version: 5.6.0 Block user comment: N Private report: N New Comment: Automatic comment on behalf of cmb Revision: http://git.php.net/?p=php-src.git;a=commit;h=7ab39e2faef499c8a1857205fa332d2e38a0a584 Log: Fix #67976: cal_days_month() fails for final month of the French calendar Previous Comments: ------------------------------------------------------------------------ [2014-09-08 10:04:16] 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=67976&edit=1

« previous php.bugs (#202680) next »