]> granicus.if.org Git - php/commitdiff
- MFH: Fixed bug #45696 (Not all DateTime methods allow method chaining).
authorDerick Rethans <derick@php.net>
Sun, 3 Aug 2008 16:45:15 +0000 (16:45 +0000)
committerDerick Rethans <derick@php.net>
Sun, 3 Aug 2008 16:45:15 +0000 (16:45 +0000)
NEWS
ext/date/php_date.c

diff --git a/NEWS b/NEWS
index e37f0108fd92e6ccf0c7d9a70f9a894f3ec92ed7..f7cd9b8b660283d5fea296f87675fea77495e22c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
 PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 200?, PHP 5.3.0 Alpha 2
+- Fixed bug #45696 (Not all DateTime methods allow method chaining). (Derick)
 - Fixed bug #45545 (DateInterval has a limitation of 4 chars for ISO
   durations). (Derick)
 - Fixed bug #44100 (Inconsistent handling of static array declarations with
index 50646eb65e3a9b307791e3537e0f8dfb2a7f637d..ffa6116804b3f8634d1e72bcaa0a71ff2e950795 100644 (file)
@@ -2825,23 +2825,29 @@ PHP_FUNCTION(date_add)
        intobj = (php_interval_obj *) zend_object_store_get_object(interval TSRMLS_CC);
        DATE_CHECK_INITIALIZED(intobj->initialized, DateInterval);
 
-       if (intobj->diff->invert) {
-               bias = -1;
-       }
 
-       dateobj->time->relative.y = intobj->diff->y * bias;
-       dateobj->time->relative.m = intobj->diff->m * bias;
-       dateobj->time->relative.d = intobj->diff->d * bias;
-       dateobj->time->relative.h = intobj->diff->h * bias;
-       dateobj->time->relative.i = intobj->diff->i * bias;
-       dateobj->time->relative.s = intobj->diff->s * bias;
+       if (intobj->diff->have_weekday_relative || intobj->diff->have_special_relative) {
+               memcpy(&dateobj->time->relative, intobj->diff, sizeof(struct timelib_rel_time));
+       } else {
+               if (intobj->diff->invert) {
+                       bias = -1;
+               }
+               dateobj->time->relative.y = intobj->diff->y * bias;
+               dateobj->time->relative.m = intobj->diff->m * bias;
+               dateobj->time->relative.d = intobj->diff->d * bias;
+               dateobj->time->relative.h = intobj->diff->h * bias;
+               dateobj->time->relative.i = intobj->diff->i * bias;
+               dateobj->time->relative.s = intobj->diff->s * bias;
+               dateobj->time->relative.weekday = 0;
+               dateobj->time->relative.have_weekday_relative = 0;
+       }
        dateobj->time->have_relative = 1;
-       dateobj->time->relative.weekday = 0;
-       dateobj->time->relative.have_weekday_relative = 0;
        dateobj->time->sse_uptodate = 0;
 
        timelib_update_ts(dateobj->time, NULL);
        timelib_update_from_sse(dateobj->time);
+
+       RETURN_ZVAL(object, 1, 0);
 }
 /* }}} */
 
@@ -2880,6 +2886,8 @@ PHP_FUNCTION(date_sub)
 
        timelib_update_ts(dateobj->time, NULL);
        timelib_update_from_sse(dateobj->time);
+
+       RETURN_ZVAL(object, 1, 0);
 }
 /* }}} */