Skip to content

Commit d22cc5c

Browse files
committed
Fixed bug #65199 (Wrong Day of Week) and fixed bug #63391 (Incorrect/inconsistent day of week prior to the year 1600)
1 parent c1eb219 commit d22cc5c

File tree

4 files changed

+27
-10
lines changed

4 files changed

+27
-10
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ PHP NEWS
44

55
- Date:
66
. Fixed bug #66060 (Heap buffer over-read in DateInterval). (Remi)
7+
. Fixed bug #63391 (Incorrect/inconsistent day of week prior to the year
8+
1600). (Derick, T. Carter)
9+
. Fixed bug #61599 (Wrong Day of Week). (Derick, T. Carter)
710

811
?? ??? 2013, PHP 5.4.23
912

ext/date/lib/dow.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,16 @@ static int m_table_leap[13] = { -1, 6, 2, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5 }; /* 1
2525

2626
static timelib_sll century_value(timelib_sll j)
2727
{
28-
timelib_sll i = j - 17;
29-
timelib_sll c = (4 - i * 2 + (i + 1) / 4) % 7;
30-
31-
return c < 0 ? c + 7 : c;
28+
return 6 - (j % 4) * 2;
3229
}
3330

3431
static timelib_sll timelib_day_of_week_ex(timelib_sll y, timelib_sll m, timelib_sll d, int iso)
3532
{
3633
timelib_sll c1, y1, m1, dow;
3734

3835
/* Only valid for Gregorian calendar, commented out as we don't handle
39-
* julian calendar. We just return the 'wrong' day of week to be
40-
* consistent.
41-
if (y < 1753) {
42-
return -1;
43-
} */
36+
* Julian calendar. We just return the 'wrong' day of week to be
37+
* consistent. */
4438
c1 = century_value(y / 100);
4539
y1 = (y % 100);
4640
m1 = timelib_is_leap(y) ? m_table_leap[m] : m_table_common[m];

ext/date/tests/bug63391.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Test for #63391 (Incorrect/inconsistent day of week prior to the year 1600)
3+
--FILE--
4+
<?php
5+
ini_set('date.timezone', 'UTC');
6+
7+
print "Date PHP\n";
8+
print "---------- ---\n";
9+
$dates = array('1599-12-30', '1599-12-31', '1600-01-01', '1600-01-02');
10+
foreach ($dates as $date) {
11+
echo date_create($date)->format('Y-m-d D'), "\n";
12+
}
13+
?>
14+
--EXPECT--
15+
Date PHP
16+
---------- ---
17+
1599-12-30 Thu
18+
1599-12-31 Fri
19+
1600-01-01 Sat
20+
1600-01-02 Sun

ext/date/tests/strtotime3-64bit.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ bool(false)
5353
string(31) "Fri, 16 Jun 2006 23:49:12 +0100"
5454
bool(false)
5555
string(31) "Fri, 16 Jun 2006 02:22:00 +0100"
56-
string(31) "Mon, 16 Jun 0222 02:22:00 -0036"
56+
string(31) "Sun, 16 Jun 0222 02:22:00 -0036"
5757
string(31) "Fri, 16 Jun 2006 02:22:33 +0100"
5858
bool(false)
5959
string(31) "Tue, 02 Mar 2004 00:00:00 +0000"

0 commit comments

Comments
 (0)