Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ PHP NEWS
- Curl:
. Fixed curl_reset() retaining CURLOPT_PRIVATE after reset. (lacatoire)

- Date:
. Fixed truncated timezone name for UTC offsets of 100 hours or more
created by DateTime::createFromFormat(). (Jorg Sowa)

- DBA:
. Fixed dba_close() not closing a database opened with dba_popen().
(Ilia Alshanetsky)
Expand Down
9 changes: 1 addition & 8 deletions ext/date/php_date.c
Original file line number Diff line number Diff line change
Expand Up @@ -1940,27 +1940,20 @@ static HashTable *date_object_get_gc_timezone(zend_object *object, zval **table,
static zend_string *date_create_tz_offset_str(timelib_sll offset)
{
int seconds = offset % 60;
size_t size;
const char *format;

if (seconds == 0) {
size = sizeof("+05:00");
format = "%c%02d:%02d";
} else {
size = sizeof("+05:00:01");
format = "%c%02d:%02d:%02d";
}

zend_string *tmpstr = zend_string_alloc(size - 1, 0);

/* Note: if seconds == 0, the seconds argument will be excessive and therefore ignored. */
ZSTR_LEN(tmpstr) = snprintf(ZSTR_VAL(tmpstr), size, format,
return zend_strpprintf(0, format,
offset < 0 ? '-' : '+',
abs((int)(offset / 3600)),
abs((int)(offset % 3600) / 60),
abs(seconds));

return tmpstr;
}

static void date_object_to_hash(php_date_obj *dateobj, HashTable *props)
Expand Down
8 changes: 8 additions & 0 deletions ext/date/tests/createFromFormat_offset_over_99_hours.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
--TEST--
DateTime::createFromFormat() with UTC offset of 100 hours or more
--FILE--
<?php
var_dump(DateTime::createFromFormat('O', '+9999')->getTimezone()->getName());
?>
--EXPECT--
string(7) "+100:39"
Loading