diff options
author | Derick Rethans <derick@php.net> | 2005-09-02 14:57:42 +0000 |
---|---|---|
committer | Derick Rethans <derick@php.net> | 2005-09-02 14:57:42 +0000 |
commit | 5169c325738042afdf1fa13dde6c7fe3b2ca9ff6 (patch) | |
tree | fbc7189a42b2ab3b5f789f829b670990e7f716fa | |
parent | 7d92b356d9846c632c09331afac44e3be83687f6 (diff) | |
download | php-git-5169c325738042afdf1fa13dde6c7fe3b2ca9ff6.tar.gz |
- Added date_time_set, date_date_set and date_isodate_set() functions, and
setTime, setDate and setISODate() methods.
-rw-r--r-- | ext/date/php_date.c | 58 | ||||
-rw-r--r-- | ext/date/php_date.h | 4 |
2 files changed, 62 insertions, 0 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 719f017177..ad5ffea94f 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -57,6 +57,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) @@ -78,6 +82,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} }; @@ -1290,6 +1297,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 a9c8dcf37b..028b79a0c3 100644 --- a/ext/date/php_date.h +++ b/ext/date/php_date.h @@ -52,6 +52,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); |