PHP outputs wrong day of the week for dates until 1600
OpenPublic

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

bzimport added projects: MediaWiki-Parser, Upstream.Via ConduitNov 22 2014, 1:38 AM
bzimport added a subscriber: wikibugs-l.
bzimport set Reference to bz48907.
bzimport created this task.Via LegacyMay 28 2013, 7:05 PM
bzimport added a comment.Via ConduitMay 28 2013, 7:07 PM

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."

bzimport added a comment.Via ConduitMay 28 2013, 7:24 PM

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

bzimport added a comment.Via ConduitMay 28 2013, 8:08 PM

paul wrote:

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

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

Add Comment

Column Prototype
This is a very early prototype of a persistent column. It is not expected to work yet, and leaving it open will activate other new features which will break things. Press "\" (backslash) on your keyboard to close it now.