summaryrefslogtreecommitdiff
path: root/ext/date/php_date.c
diff options
context:
space:
mode:
authorDerick Rethans <github@derickrethans.nl>2014-01-26 13:58:13 +0100
committerDerick Rethans <github@derickrethans.nl>2014-01-26 14:01:58 +0100
commit22dba2f5f3211efe6c3b9bb24734c811ca64c68c (patch)
treeb1b110836acc9f9943d3561635813f214ea9cca9 /ext/date/php_date.c
parent4e308abf28d542de0f1251b5e5c523d4701af4b4 (diff)
downloadphp-git-22dba2f5f3211efe6c3b9bb24734c811ca64c68c.tar.gz
Fixed bug #45543: DateTime::setTimezone can not set timezones without ID.
Diffstat (limited to 'ext/date/php_date.c')
-rw-r--r--ext/date/php_date.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 1655057212..c0566334db 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -2992,11 +2992,18 @@ PHP_FUNCTION(date_timezone_set)
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);
RETURN_ZVAL(object, 1, 0);