From:             satovey at yahoo dot com
Operating system: Windows 7
PHP version:      Irrelevant
Package:          Built-in web server
Bug Type:         Bug
Bug description:Php Calendar does not calculate number of days correctly

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 bug report at https://bugs.php.net/bug.php?id=65578&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=65578&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=65578&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=65578&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=65578&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=65578&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=65578&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=65578&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=65578&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=65578&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=65578&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=65578&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=65578&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=65578&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65578&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=65578&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=65578&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=65578&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65578&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=65578&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=65578&r=mysqlcfg

Reply via email to