diff options
author | Derick Rethans <github@derickrethans.nl> | 2014-01-02 12:47:44 +0000 |
---|---|---|
committer | Derick Rethans <github@derickrethans.nl> | 2014-01-02 12:47:44 +0000 |
commit | 110b7dcfb887c352f9ab73762ed5c8b68055c28f (patch) | |
tree | 7889472794608dd3ef5aadaebbb66c29762fae15 /ext/date | |
parent | 8a7e2f8dd2116ff6ada654e301c593accf337250 (diff) | |
parent | 5137cb5f0ccdeb78d6db25f6045b2c520463a38f (diff) | |
download | php-git-110b7dcfb887c352f9ab73762ed5c8b68055c28f.tar.gz |
Merge branch 'PHP-5.5' into PHP-5.6
Diffstat (limited to 'ext/date')
-rw-r--r-- | ext/date/php_date.c | 48 |
1 files changed, 8 insertions, 40 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c index cd3bf745dc..d96428d5e5 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -3137,33 +3137,16 @@ static void php_date_add(zval *object, zval *interval, zval *return_value TSRMLS { php_date_obj *dateobj; php_interval_obj *intobj; - int bias = 1; + timelib_time *new_time; dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC); DATE_CHECK_INITIALIZED(dateobj->time, DateTime); intobj = (php_interval_obj *) zend_object_store_get_object(interval TSRMLS_CC); DATE_CHECK_INITIALIZED(intobj->initialized, DateInterval); - 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; - } - memset(&dateobj->time->relative, 0, sizeof(struct timelib_rel_time)); - 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->have_relative = 1; - dateobj->time->sse_uptodate = 0; - - timelib_update_ts(dateobj->time, NULL); - timelib_update_from_sse(dateobj->time); - dateobj->time->have_relative = 0; + new_time = timelib_add(dateobj->time, intobj->diff); + timelib_time_dtor(dateobj->time); + dateobj->time = new_time; } /* {{{ proto DateTime date_add(DateTime object, DateInterval interval) @@ -3204,7 +3187,7 @@ static void php_date_sub(zval *object, zval *interval, zval *return_value TSRMLS { php_date_obj *dateobj; php_interval_obj *intobj; - int bias = 1; + timelib_time *new_time; dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC); DATE_CHECK_INITIALIZED(dateobj->time, DateTime); @@ -3216,24 +3199,9 @@ static void php_date_sub(zval *object, zval *interval, zval *return_value TSRMLS return; } - if (intobj->diff->invert) { - bias = -1; - } - - memset(&dateobj->time->relative, 0, sizeof(struct timelib_rel_time)); - dateobj->time->relative.y = 0 - (intobj->diff->y * bias); - dateobj->time->relative.m = 0 - (intobj->diff->m * bias); - dateobj->time->relative.d = 0 - (intobj->diff->d * bias); - dateobj->time->relative.h = 0 - (intobj->diff->h * bias); - dateobj->time->relative.i = 0 - (intobj->diff->i * bias); - dateobj->time->relative.s = 0 - (intobj->diff->s * bias); - dateobj->time->have_relative = 1; - dateobj->time->sse_uptodate = 0; - - timelib_update_ts(dateobj->time, NULL); - timelib_update_from_sse(dateobj->time); - - dateobj->time->have_relative = 0; + new_time = timelib_sub(dateobj->time, intobj->diff); + timelib_time_dtor(dateobj->time); + dateobj->time = new_time; } /* {{{ proto DateTime date_sub(DateTime object, DateInterval interval) |