Edit report at https://bugs.php.net/bug.php?id=65578&edit=1
ID: 65578 Updated by: requi...@php.net Reported by: satovey at yahoo dot com Summary: Php Calendar does not calculate number of days correctly -Status: Open +Status: Not a bug Type: Bug -Package: Built-in web server +Package: Calendar related Operating System: Windows 7 PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. Your arithmetic is off by one: using January to demonstrate, you're subtracting January 31st minus January 1st and concluding that there are 31-1=30 days in the month. $totalDaysInYear = $lastDay - $firstDay + 1; Previous Comments: ------------------------------------------------------------------------ [2013-08-28 23:08:32] satovey at yahoo dot com Description: ------------ --- >From manual page: http://www.php.net/function.jewishtojd --- In using the JewishToJD function of the Calendar, there is a discrepancy in the total days of the year. The last month of the Jewish Year has 29 days and the shortest year is 353 days. Test script: --------------- <?PHP $year = "5777"; $firstDate = "1/1/$year"; $lastDate = "13/30/$year"; $count=1; calculateTotalDays($firstDate, $lastDate, $year, $count); $firstDate = "1/1/$year"; $lastDate = "13/29/$year"; $count=1; calculateTotalDays($firstDate, $lastDate, $year, $count); function calculateTotalDays($firstDate, $lastDate, $year, $count) { $count++; $displayYear = $year; list($firstMonth, $firstDay, $firstYear) = explode("/",$firstDate); list($lastMonth, $lastDay, $lastYear) = explode("/",$lastDate); if ($year < 0) { $firstYear = $firstYear + 248; $lastYear = $lastYear + 248; //echo "less than 0 => $year<br />"; } $firstDay = jewishtojd( $firstMonth, $firstDay, $firstYear ); $lastDay = jewishtojd ( $lastMonth, $lastDay, $lastYear ); $totalDaysInYear = $lastDay - $firstDay; //echo "$firstDate, $lastDate <br />"; //echo "Cycle Count -> $count | Total Days in the Year $year => "; echo "$displayYear "; echo "$totalDaysInYear"; echo "<br />"; } ?> Expected result: ---------------- It is expected that when calculating between 1/1/577 to 13/29/577 the return should be 353 days as that is the number of days in the Jewish year 5777. http://en.wikipedia.org/wiki/Hebrew_calendar#Leap_years >> Scroll up to see a list of new year dates. << This appears to occur in all versions of PHP. Actual result: -------------- Yet the provided code will output 352 days if 13,29,5777 is entered and 353 days if 13,30,5777 is entered. Note: the month of Elul which is given the number 13 is a 29 day month. The output is as follows: 5777 353 5777 352 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=65578&edit=1