Page MenuHomePhabricator

PHP outputs wrong day of the week for dates until 1600
Closed, ResolvedPublic

Description

Author: paul

Description:
Not sure if this is a wikimedia error or a PHP error. The day of week for 1/1/1600 is correct as Saturday. The day of week for 1-1-1599 is incorrect as Friday.

Place the following in any wikipedia page:

Today: 2013-05-28 is {{#time:l|2013-05-28}},
, 2013 is {{#time:l|2013-01-01}}
, 1901 is {{#time:l|1901-01-01}}
, 1900 is {{#time:l|1900-01-01}}
, 1601 is {{#time:l|1601-01-01}}
, 1600 is {{#time:l|1600-01-01}}.<br>
Year 1599 is {{#time:l|1599-01-01}}
, 1598 is {{#time:l|1598-01-01}}
, 1597 is {{#time:l|1597-01-01}}
, 1596 is {{#time:l|1596-01-01}}
, 1595 is {{#time:l|1595-01-01}}
, 1594 is {{#time:l|1594-01-01}}
, 1593 is {{#time:l|1593-01-01}}.<br/>

This returns:

Today: 2013-05-28 is Tuesday, , 2013 is Tuesday , 1901 is Tuesday , 1900 is Monday , 1601 is Monday , 1600 is Saturday.
Year 1599 is Saturday , 1598 is Friday , 1597 is Thursday , 1596 is Tuesday , 1595 is Monday , 1594 is Sunday , 1593 is Saturday.

This is correct for today, 2013, 1901 and 1900.
This is correct for 1600 and 1601. This is incorrect for 1599 and I'm not sure how far back. 1599 started on a Friday, 1598 on a Thursday, 1597 on Wednesday, 1596 on Monday, 1595 on Sunday, etc. Oh, and it's not Julian/Gregorian error, these are Gregorian days.

I did this on an old automatically erased test template, the old revision of which can be viewed here:

http://en.wikipedia.org/w/index.php?title=Template:X8&oldid=557212409

Wikimedia version is 1.22 wmf 4, as running on en.wikipedia.org as of today, 5/28/13.


Version: 1.22.0
Severity: minor

Details

Reference
bz48907

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 1:38 AM
bzimport set Reference to bz48907.
bzimport added a subscriber: Unknown Object (MLST).

paul wrote:

Correction, I said, "The day of week for 1-1-1599 is incorrect as
Friday." this should read, "The day of week for 1-1-1599 is incorrect as it should be Friday."

paul wrote:

Confirmed, this is not a Wikimedia bug, this is a bug in php:

<?php
$h = mktime(0, 0, 0, 1, 1, 1600);
$d = date("F dS, Y", $h) ;
$w= date("l", $h) ;
Echo "$d is on a $w<br>";
$h = mktime(0, 0, 0, 1, 1, 1599);
$d = date("F dS, Y", $h) ;
$w= date("l", $h) ;
Echo "$d is on a $w<br>";
?>

Results:

January 01st, 1600 is on a Saturday
January 01st, 1599 is on a Saturday

paul wrote:

This bug has been reported to PHP.NET, the bug number is 61599

https://bugs.php.net/bug.php?id=61599

Mainframe98 edited subscribers, added: Mainframe98; removed: wikibugs-l-list.

This bug has been fixed in PHP 5.3.10, which has been unsupported by MediaWiki for years.