|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67960 Long/short day names reversed in jddayofweek()
Submitted: 2014-09-04 13:34 UTC Modified: 2015-01-02 09:23 UTC
From: fisharebest at gmail dot com Assigned: tyrael (profile)
Status: Closed Package: Calendar related
PHP Version: 5.6.0 OS: All
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: fisharebest at gmail dot com
New email:
PHP Version: OS:


 [2014-09-04 13:34 UTC] fisharebest at gmail dot com
From manual page:

The $mode parameter is an integer (0, 1 or 2) for which
predefined constants are also available.

Numeric parameters work as per the documentation:
0 = numeric
1 = long name
2 = short name

But if the constants CAL_DOW_LONG and CAL_DOW_SHORT are used,
the wrong results are returned.  CAL_DOW_LONG gives the short
name and CAL_DOW_SHORT gives the long name.

The bug is present in all versions of PHP from 5.3 through 5.6.

Test script:
print_r(jddayofweek(1234567, 1)); // "Saturday"
print_r(jddayofweek(1234567, CAL_DOW_LONG)); // "Sat" (WRONG)
print_r(CAL_DOW_LONG); // 2

print_r(jddayofweek(1234567, 2)); // "Sat"
print_r(CAL_DOW_SHORT); // 1
print_r(jddayofweek(1234567, CAL_DOW_SHORT)); // "Saturday" (WRONG)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-09-04 14:07 UTC]
-Status: Open +Status: Verified
 [2014-09-04 14:07 UTC]
haha, nice catch, this seems to be wrong since the begining:
the fix should be swapping the lines here:
I suppose this could also go into 5.5 as well.
 [2014-09-04 14:07 UTC]
-Assigned To: +Assigned To: tyrael
 [2014-09-04 15:29 UTC] fisharebest at gmail dot com
I think you need to:

1) reverse the order in the enum {} declaration
2) reverse the two labels in the case statement

I have a patch/tests, but can't get the latest code to build so can't test it.

I'll try again tonight when I have access to another dev machine.
 [2014-09-04 15:39 UTC]
why do you think we should change the order of declaration in the enum?
 [2014-09-04 15:53 UTC]
ah, that would keep the previous behavior for the people who are passing numeric values for the mode instead of using the constants.
 [2014-09-04 21:35 UTC] fisharebest at gmail dot com
Pull request available, with updated unit tests...
 [2015-01-02 09:22 UTC]
-Status: Verified +Status: Closed
 [2015-01-02 09:22 UTC]
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at

 For Windows:
Thank you for the report, and for helping us make PHP better.

 [2015-01-02 09:23 UTC]
merged to 5.5 and upwards, will be part of the next release.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jun 13 05:01:35 2024 UTC