derick Fri Sep 2 05:33:09 2005 EDT
Added files: (Branch: PHP_5_1)
/php-src/ext/date/tests bug34304.phpt
Modified files:
/php-src NEWS
/php-src/ext/date php_date.c
/php-src/ext/date/lib dow.c timelib.h
Log:
- Fixed bug #34304 (date() doesn't have a modifier for ISO Week Day).
http://cvs.php.net/diff.php/php-src/NEWS?r1=1.2027.2.47&r2=1.2027.2.48&ty=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.47 php-src/NEWS:1.2027.2.48
--- php-src/NEWS:1.2027.2.47 Fri Sep 2 05:13:58 2005
+++ php-src/NEWS Fri Sep 2 05:33:05 2005
@@ -25,6 +25,7 @@
- Fixed bug #34310 (foreach($arr as $c->d => $x) crashes). (Dmitry)
- Fixed bug #34307 (OnUpdateStringUnempty INI options can be set empty). (Jani)
- Fixed bug #34306 (wddx_serialize_value() crashes with long array keys).
(Jani)
+- Fixed bug #34304 (date() doesn't have a modifier for ISO Week Day). (Derick)
- Fixed bug #34302 (date('W') do not return leading zeros for week 1 to 9).
(Derick)
- Fixed bug #34299 (ReflectionClass::isInstantiable() returns true for abstract
http://cvs.php.net/diff.php/php-src/ext/date/php_date.c?r1=1.43.2.3&r2=1.43.2.4&ty=u
Index: php-src/ext/date/php_date.c
diff -u php-src/ext/date/php_date.c:1.43.2.3
php-src/ext/date/php_date.c:1.43.2.4
--- php-src/ext/date/php_date.c:1.43.2.3 Tue Aug 30 05:17:09 2005
+++ php-src/ext/date/php_date.c Fri Sep 2 05:33:08 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_date.c,v 1.43.2.3 2005/08/30 09:17:09 derick Exp $ */
+/* $Id: php_date.c,v 1.43.2.4 2005/09/02 09:33:08 derick Exp $ */
#include "php.h"
#include "php_streams.h"
@@ -389,6 +389,7 @@
case 'l': snprintf(buffer, 32, "%s",
day_full_names[timelib_day_of_week(t->y, t->m, t->d)]); break;
case 'S': snprintf(buffer, 32, "%s",
english_suffix(t->d)); break;
case 'w': snprintf(buffer, 32, "%d", (int)
timelib_day_of_week(t->y, t->m, t->d)); break;
+ case 'N': snprintf(buffer, 32, "%d", (int)
timelib_iso_day_of_week(t->y, t->m, t->d)); break;
case 'z': snprintf(buffer, 32, "%d", (int)
timelib_day_of_year(t->y, t->m, t->d)); break;
/* week */
http://cvs.php.net/diff.php/php-src/ext/date/lib/dow.c?r1=1.8.2.1&r2=1.8.2.2&ty=u
Index: php-src/ext/date/lib/dow.c
diff -u php-src/ext/date/lib/dow.c:1.8.2.1 php-src/ext/date/lib/dow.c:1.8.2.2
--- php-src/ext/date/lib/dow.c:1.8.2.1 Wed Aug 31 10:29:23 2005
+++ php-src/ext/date/lib/dow.c Fri Sep 2 05:33:08 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dow.c,v 1.8.2.1 2005/08/31 14:29:23 derick Exp $ */
+/* $Id: dow.c,v 1.8.2.2 2005/09/02 09:33:08 derick Exp $ */
#include "timelib.h"
@@ -31,9 +31,9 @@
return c < 0 ? c + 7 : c;
}
-timelib_sll timelib_day_of_week(timelib_sll y, timelib_sll m, timelib_sll d)
+static timelib_sll timelib_day_of_week_ex(timelib_sll y, timelib_sll m,
timelib_sll d, int iso)
{
- timelib_sll c1, y1, m1;
+ timelib_sll c1, y1, m1, dow;
/* Only valid for Gregorian calendar */
if (y < 1753) {
@@ -42,7 +42,23 @@
c1 = century_value(y / 100);
y1 = (y % 100);
m1 = timelib_is_leap(y) ? m_table_leap[m] : m_table_common[m];
- return (c1 + y1 + m1 + (y1 / 4) + d) % 7;
+ dow = (c1 + y1 + m1 + (y1 / 4) + d) % 7;
+ if (iso) {
+ if (dow == 0) {
+ dow = 7;
+ }
+ }
+ return dow;
+}
+
+timelib_sll timelib_day_of_week(timelib_sll y, timelib_sll m, timelib_sll d)
+{
+ return timelib_day_of_week_ex(y, m, d, 0);
+}
+
+timelib_sll timelib_iso_day_of_week(timelib_sll y, timelib_sll m, timelib_sll
d)
+{
+ return timelib_day_of_week_ex(y, m, d, 1);
}
/* jan feb mar apr may jun jul aug
sep oct nov dec */
http://cvs.php.net/diff.php/php-src/ext/date/lib/timelib.h?r1=1.10.2.1&r2=1.10.2.2&ty=u
Index: php-src/ext/date/lib/timelib.h
diff -u php-src/ext/date/lib/timelib.h:1.10.2.1
php-src/ext/date/lib/timelib.h:1.10.2.2
--- php-src/ext/date/lib/timelib.h:1.10.2.1 Thu Aug 25 05:47:27 2005
+++ php-src/ext/date/lib/timelib.h Fri Sep 2 05:33:08 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: timelib.h,v 1.10.2.1 2005/08/25 09:47:27 derick Exp $ */
+/* $Id: timelib.h,v 1.10.2.2 2005/09/02 09:33:08 derick Exp $ */
#ifndef __TIMELIB_H__
#define __TIMELIB_H__
@@ -40,6 +40,7 @@
/* From dow.c */
timelib_sll timelib_day_of_week(timelib_sll y, timelib_sll m, timelib_sll d);
+timelib_sll timelib_iso_day_of_week(timelib_sll y, timelib_sll m, timelib_sll
d);
timelib_sll timelib_day_of_year(timelib_sll y, timelib_sll m, timelib_sll d);
timelib_sll timelib_daynr_from_weeknr(timelib_sll y, timelib_sll w,
timelib_sll d);
timelib_sll timelib_days_in_month(timelib_sll y, timelib_sll m);
http://cvs.php.net/co.php/php-src/ext/date/tests/bug34304.phpt?r=1.1&p=1
Index: php-src/ext/date/tests/bug34304.phpt
+++ php-src/ext/date/tests/bug34304.phpt
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php