From: Derick Rethans Date: Fri, 2 Sep 2005 14:58:01 +0000 (+0000) Subject: - MFH: Added date_time_set, date_date_set and date_isodate_set() functions, and X-Git-Tag: php-5.1.0RC2_PRE~17 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=abcfcd3f2e6c710412c34c5cfe7612b3246f3167;p=php - MFH: Added date_time_set, date_date_set and date_isodate_set() functions, and setTime, setDate and setISODate() methods. --- diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 2cbac27478..bfce6aa418 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -55,6 +55,10 @@ function_entry date_functions[] = { PHP_FE(date_timezone_set, NULL) PHP_FE(date_offset_get, NULL) + PHP_FE(date_time_set, NULL) + PHP_FE(date_date_set, NULL) + PHP_FE(date_isodate_set, NULL) + PHP_FE(timezone_open, NULL) PHP_FE(timezone_name_get, NULL) PHP_FE(timezone_offset_get, NULL) @@ -76,6 +80,9 @@ function_entry date_funcs_date[] = { ZEND_NAMED_FE(getTimezone, ZEND_FN(date_timezone_get), NULL) ZEND_NAMED_FE(setTimezone, ZEND_FN(date_timezone_set), NULL) ZEND_NAMED_FE(getOffset, ZEND_FN(date_offset_get), NULL) + ZEND_NAMED_FE(setTime, ZEND_FN(date_time_set), NULL) + ZEND_NAMED_FE(setDate, ZEND_FN(date_date_set), NULL) + ZEND_NAMED_FE(setISODate, ZEND_FN(date_isodate_set), NULL) {NULL, NULL, NULL} }; @@ -1155,6 +1162,57 @@ PHP_FUNCTION(date_offset_get) } } +PHP_FUNCTION(date_time_set) +{ + zval *object; + php_date_obj *dateobj; + long h, i, s = 0; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oll|l", &object, date_ce_date, &h, &i, &s) == FAILURE) { + RETURN_FALSE; + } + dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC); + dateobj->time->h = h; + dateobj->time->i = i; + dateobj->time->s = s; + timelib_update_ts(dateobj->time, NULL); +} + +PHP_FUNCTION(date_date_set) +{ + zval *object; + php_date_obj *dateobj; + long y, m, d; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Olll", &object, date_ce_date, &y, &m, &d) == FAILURE) { + RETURN_FALSE; + } + dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC); + dateobj->time->y = y; + dateobj->time->m = m; + dateobj->time->d = d; + timelib_update_ts(dateobj->time, NULL); +} + +PHP_FUNCTION(date_isodate_set) +{ + zval *object; + php_date_obj *dateobj; + long y, w, d = 1; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oll|l", &object, date_ce_date, &y, &w, &d) == FAILURE) { + RETURN_FALSE; + } + dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC); + dateobj->time->y = y; + dateobj->time->m = 1; + dateobj->time->d = 1; + dateobj->time->relative.d = timelib_daynr_from_weeknr(y, w, d); + dateobj->time->have_relative = 1; + + timelib_update_ts(dateobj->time, NULL); +} + PHP_FUNCTION(timezone_open) { diff --git a/ext/date/php_date.h b/ext/date/php_date.h index 87c2311e7c..253ad2f44f 100644 --- a/ext/date/php_date.h +++ b/ext/date/php_date.h @@ -51,6 +51,10 @@ PHP_FUNCTION(date_timezone_get); PHP_FUNCTION(date_timezone_set); PHP_FUNCTION(date_offset_get); +PHP_FUNCTION(date_time_set); +PHP_FUNCTION(date_date_set); +PHP_FUNCTION(date_isodate_set); + PHP_FUNCTION(timezone_open); PHP_FUNCTION(timezone_name_get); PHP_FUNCTION(timezone_offset_get);