diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2018-06-08 23:10:43 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2018-06-08 23:10:43 +0200 |
commit | e0290192752a72b5be35b033b33590e040d60d24 (patch) | |
tree | b61f007474c5b17cfbb04cd642d248280df4281a /ext/date | |
parent | ad52ec3db8d10e88279c73a7c7209c2ffdf230c1 (diff) | |
download | php-git-e0290192752a72b5be35b033b33590e040d60d24.tar.gz |
Deduplicate code using php_timezone_to_string()
Looks like this usage was overlooked when the function was
introduced.
Diffstat (limited to 'ext/date')
-rw-r--r-- | ext/date/php_date.c | 65 |
1 files changed, 23 insertions, 42 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 1788d8fed5..1ac7ad214e 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -2358,48 +2358,6 @@ static zend_object *date_object_clone_timezone(zval *this_ptr) /* {{{ */ return &new_obj->std; } /* }}} */ -static HashTable *date_object_get_properties_timezone(zval *object) /* {{{ */ -{ - HashTable *props; - zval zv; - php_timezone_obj *tzobj; - - - tzobj = Z_PHPTIMEZONE_P(object); - - props = zend_std_get_properties(object); - - if (!tzobj->initialized) { - return props; - } - - ZVAL_LONG(&zv, tzobj->type); - zend_hash_str_update(props, "timezone_type", sizeof("timezone_type")-1, &zv); - - switch (tzobj->type) { - case TIMELIB_ZONETYPE_ID: - ZVAL_STRING(&zv, tzobj->tzi.tz->name); - break; - case TIMELIB_ZONETYPE_OFFSET: { - zend_string *tmpstr = zend_string_alloc(sizeof("UTC+05:00")-1, 0); - - ZSTR_LEN(tmpstr) = snprintf(ZSTR_VAL(tmpstr), sizeof("+05:00"), "%c%02d:%02d", - tzobj->tzi.utc_offset < 0 ? '-' : '+', - abs(tzobj->tzi.utc_offset / 3600), - abs(((tzobj->tzi.utc_offset % 3600) / 60))); - - ZVAL_NEW_STR(&zv, tmpstr); - } - break; - case TIMELIB_ZONETYPE_ABBR: - ZVAL_STRING(&zv, tzobj->tzi.z.abbr); - break; - } - zend_hash_str_update(props, "timezone", sizeof("timezone")-1, &zv); - - return props; -} /* }}} */ - static void php_timezone_to_string(php_timezone_obj *tzobj, zval *zv) { switch (tzobj->type) { @@ -2424,6 +2382,29 @@ static void php_timezone_to_string(php_timezone_obj *tzobj, zval *zv) } } +static HashTable *date_object_get_properties_timezone(zval *object) /* {{{ */ +{ + HashTable *props; + zval zv; + php_timezone_obj *tzobj; + + tzobj = Z_PHPTIMEZONE_P(object); + + props = zend_std_get_properties(object); + + if (!tzobj->initialized) { + return props; + } + + ZVAL_LONG(&zv, tzobj->type); + zend_hash_str_update(props, "timezone_type", sizeof("timezone_type")-1, &zv); + + php_timezone_to_string(tzobj, &zv); + zend_hash_str_update(props, "timezone", sizeof("timezone")-1, &zv); + + return props; +} /* }}} */ + static HashTable *date_object_get_debug_info_timezone(zval *object, int *is_temp) /* {{{ */ { HashTable *ht, *props; |