php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54254 cal_from_jd returns month = 6 when there is only one Adar
Submitted: 2011-03-15 09:53 UTC Modified: 2012-08-07 08:49 UTC
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:2 (66.7%)
From: asphp at dsgml dot com Assigned: stas
Status: Closed Package: Calendar related
PHP Version: 5.3.5 OS:
Private report: No CVE-ID:
 [2011-03-15 09:53 UTC] asphp at dsgml dot com
Description:
------------
cal_from_jd() returns 6 for Adar when there is only one Adar, (it should return 7, since if there is only one Adar it's AdarII).

It also says "AdarI", which is wrong (it should be either "Adar" or at least "AdarII").

Furthermore the cal_days_in_month() (correctly) only works with month 7, and not 6 as returned by cal_from_jd.

Test script:
---------------
<?
print_r(cal_from_jd(2456005, CAL_JEWISH));
echo cal_days_in_month(CAL_JEWISH, 6, 5772) . "\n";
echo cal_days_in_month(CAL_JEWISH, 7, 5772) . "\n";
?>


Expected result:
----------------
The month in cal_from_jd should be 7.

The second two lines demonstrate how cal_days_in_month also expects the month to be 7.

Actual result:
--------------
Array
(
    [date] => 6/24/5772
    [month] => 6
    [day] => 24
    [year] => 5772
    [dow] => 0
    [abbrevdayname] => Sun
    [dayname] => Sunday
    [abbrevmonth] => AdarI
    [monthname] => AdarI
)
0
29


Patches

Use-AdarII-for-non-leap-years-and-test (last revision 2012-01-10 20:23 UTC) by eitan at mosenkis dot net)
Use-AdarII-for-non-leap-years (last revision 2012-01-10 20:06 UTC) by eitan at mosenkis dot net)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-03-29 12:09 UTC] info at woordengeschrift dot nl
In leap years, there is only the unnumbered month of Adar.
Numbered Adars only occur in leap years: Adar_I (the actual leap month),
followed by Adar_II.
 [2012-03-29 12:13 UTC] info at woordengeschrift dot nl
In NON-leap years, there is only the unnumbered month of Adar.
 [2012-03-29 18:33 UTC] asphp at dsgml dot com
woordengeschrift you misunderstand the Hebrew calendar.

In non-leap years there is a gap, the calendar months go: 4,5,7,8 - month 6 is skipped. Unfortunately PHP does 4,5,6,8 - it skips month 7 instead of 6 which is incorrect.

In a leap year it is AdarI that is added - AdarII is the same as Adar. Yes, I know you would expect the second one to be the "extra", but that's not how the calendar works.
 [2012-08-07 08:49 UTC] stas@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: stas
 [2012-08-07 08:49 UTC] stas@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

fixed in master
 [2013-09-19 20:51 UTC] oc666 at netvision dot net dot il
I think the bug still exists.
Under 5.4.9 I get the same results like in the reproduce example:
Array
(
    [date] => 6/24/5772
    [month] => 6
    [day] => 24
    [year] => 5772
    [dow] => 0
    [abbrevdayname] => Sun
    [dayname] => Sunday
    [abbrevmonth] => AdarI
    [monthname] => AdarI
)
0
29
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 17 21:01:56 2014 UTC