com php-src: Fixed bug #65199 (Wrong Day of Week) and fixed bug #63391 (Incorrect/inconsistent day of week prior to the year 1600): NEWS
ext/date/lib/dow.c ext/date/tests/bug63391.phpt ext/date/tests/strtotime3-64bit.phpt
| From: | Derick Rethans | Date: | Thu, 28 Nov 2013 16:32:11 +0000 |
| Subject: | com php-src: Fixed bug #65199 (Wrong Day of Week) and fixed bug #63391 (Incorrect/inconsistent day of week prior to the year 1600): NEWS ext/date/lib/dow.c ext/date/tests/bug63391.phpt ext/date/tests/strtotime3-64bit.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-74140@lists.php.net to get a copy of this message | ||
Commit: d22cc5c816fdb6017ce9e22b4594d1566939e4ec
Author: Derick Rethans <github@derickrethans.nl> Thu, 28 Nov 2013 16:32:11 +0000
Parents: c1eb219aad2e23db5db27d887b93b06c1537fec9
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=d22cc5c816fdb6017ce9e22b4594d1566939e4ec
Log:
Fixed bug #65199 (Wrong Day of Week) and fixed bug #63391 (Incorrect/inconsistent day of week prior
to the year 1600)
Bugs:
https://bugs.php.net/65199
https://bugs.php.net/63391
Changed paths:
M NEWS
M ext/date/lib/dow.c
A ext/date/tests/bug63391.phpt
M ext/date/tests/strtotime3-64bit.phpt
Diff:
diff --git a/NEWS b/NEWS
index 00de79e..7aaa683 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@ PHP NEWS
- Date:
. Fixed bug #66060 (Heap buffer over-read in DateInterval). (Remi)
+ . Fixed bug #63391 (Incorrect/inconsistent day of week prior to the year
+ 1600). (Derick, T. Carter)
+ . Fixed bug #61599 (Wrong Day of Week). (Derick, T. Carter)
?? ??? 2013, PHP 5.4.23
diff --git a/ext/date/lib/dow.c b/ext/date/lib/dow.c
index b6c2d69..6c296a2 100644
--- a/ext/date/lib/dow.c
+++ b/ext/date/lib/dow.c
@@ -25,10 +25,7 @@ static int m_table_leap[13] = { -1, 6, 2, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5 }; /* 1
static timelib_sll century_value(timelib_sll j)
{
- timelib_sll i = j - 17;
- timelib_sll c = (4 - i * 2 + (i + 1) / 4) % 7;
-
- return c < 0 ? c + 7 : c;
+ return 6 - (j % 4) * 2;
}
static timelib_sll timelib_day_of_week_ex(timelib_sll y, timelib_sll m, timelib_sll d, int iso)
@@ -36,11 +33,8 @@ static timelib_sll timelib_day_of_week_ex(timelib_sll y, timelib_sll m, timelib_
timelib_sll c1, y1, m1, dow;
/* Only valid for Gregorian calendar, commented out as we don't handle
- * julian calendar. We just return the 'wrong' day of week to be
- * consistent.
- if (y < 1753) {
- return -1;
- } */
+ * Julian calendar. We just return the 'wrong' day of week to be
+ * consistent. */
c1 = century_value(y / 100);
y1 = (y % 100);
m1 = timelib_is_leap(y) ? m_table_leap[m] : m_table_common[m];
diff --git a/ext/date/tests/bug63391.phpt b/ext/date/tests/bug63391.phpt
new file mode 100644
index 0000000..a29d25e
--- /dev/null
+++ b/ext/date/tests/bug63391.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Test for #63391 (Incorrect/inconsistent day of week prior to the year 1600)
+--FILE--
+<?php
+ini_set('date.timezone', 'UTC');
+
+print "Date PHP\n";
+print "---------- ---\n";
+$dates = array('1599-12-30', '1599-12-31', '1600-01-01',
'1600-01-02');
+foreach ($dates as $date) {
+ echo date_create($date)->format('Y-m-d D'), "\n";
+}
+?>
+--EXPECT--
+Date PHP
+---------- ---
+1599-12-30 Thu
+1599-12-31 Fri
+1600-01-01 Sat
+1600-01-02 Sun
diff --git a/ext/date/tests/strtotime3-64bit.phpt b/ext/date/tests/strtotime3-64bit.phpt
index 7dc0816..3a47659 100644
--- a/ext/date/tests/strtotime3-64bit.phpt
+++ b/ext/date/tests/strtotime3-64bit.phpt
@@ -53,7 +53,7 @@ bool(false)
string(31) "Fri, 16 Jun 2006 23:49:12 +0100"
bool(false)
string(31) "Fri, 16 Jun 2006 02:22:00 +0100"
-string(31) "Mon, 16 Jun 0222 02:22:00 -0036"
+string(31) "Sun, 16 Jun 0222 02:22:00 -0036"
string(31) "Fri, 16 Jun 2006 02:22:33 +0100"
bool(false)
string(31) "Tue, 02 Mar 2004 00:00:00 +0000"