From: Derick Rethans Date: Sun, 26 Jan 2014 13:02:37 +0000 (+0100) Subject: Merge branch 'PHP-5.4' into PHP-5.5 X-Git-Tag: php-5.5.10RC1~48 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7399386a2094ccce9b5deb0c035ff6ac2aa7eb8b;p=php Merge branch 'PHP-5.4' into PHP-5.5 --- 7399386a2094ccce9b5deb0c035ff6ac2aa7eb8b diff --cc ext/date/php_date.c index c069e0ccae,c0566334db..0e21baffa6 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@@ -3284,27 -2989,22 +3284,34 @@@ static void php_date_timezone_set(zval dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC); DATE_CHECK_INITIALIZED(dateobj->time, DateTime); tzobj = (php_timezone_obj *) zend_object_store_get_object(timezone_object TSRMLS_CC); - if (tzobj->type != TIMELIB_ZONETYPE_ID) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can only do this for zones with ID for now"); - return; + + switch (tzobj->type) { + case TIMELIB_ZONETYPE_OFFSET: + timelib_set_timezone_from_offset(dateobj->time, tzobj->tzi.utc_offset); + break; + case TIMELIB_ZONETYPE_ABBR: + timelib_set_timezone_from_abbr(dateobj->time, tzobj->tzi.z); + break; + case TIMELIB_ZONETYPE_ID: + timelib_set_timezone(dateobj->time, tzobj->tzi.tz); + break; } - timelib_set_timezone(dateobj->time, tzobj->tzi.tz); timelib_unixtime2local(dateobj->time, dateobj->time->sse); +} + +/* {{{ proto DateTime date_timezone_set(DateTime object, DateTimeZone object) + Sets the timezone for the DateTime object. +*/ +PHP_FUNCTION(date_timezone_set) +{ + zval *object; + zval *timezone_object; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &object, date_ce_date, &timezone_object, date_ce_timezone) == FAILURE) { + RETURN_FALSE; + } + + php_date_timezone_set(object, timezone_object, return_value TSRMLS_CC); RETURN_ZVAL(object, 1, 0); } diff --cc ext/date/php_date.h index d4204ebd79,4ce730bb2b..d7343e02bc --- a/ext/date/php_date.h +++ b/ext/date/php_date.h @@@ -137,16 -122,10 +137,11 @@@ struct _php_timezone_obj int initialized; int type; union { - timelib_tzinfo *tz; /* TIMELIB_ZONETYPE_ID; */ - timelib_sll utc_offset; /* TIMELIB_ZONETYPE_OFFSET */ - struct /* TIMELIB_ZONETYPE_ABBR */ - { - timelib_sll utc_offset; - char *abbr; - int dst; - } z; + timelib_tzinfo *tz; /* TIMELIB_ZONETYPE_ID */ + timelib_sll utc_offset; /* TIMELIB_ZONETYPE_OFFSET */ + timelib_abbr_info z; /* TIMELIB_ZONETYPE_ABBR */ } tzi; + HashTable *props; }; struct _php_interval_obj {