diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2017-04-09 12:56:41 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2017-04-09 12:56:41 +0200 |
commit | 4ee6b52d0f4483c6e063b2dd3bb7af1c8a94300d (patch) | |
tree | 27039a0d6f0192fea4de696d27a28281eb7544b9 | |
parent | ebdbebee298a86ddddf922e2e817f101fdea4edb (diff) | |
parent | 1ce355abb648dc6814ddd00876085617a946396f (diff) | |
download | php-git-4ee6b52d0f4483c6e063b2dd3bb7af1c8a94300d.tar.gz |
Merge branch 'PHP-7.1'
-rw-r--r-- | ext/intl/common/common_date.cpp | 5 | ||||
-rw-r--r-- | ext/intl/tests/bug74298.phpt | 30 |
2 files changed, 34 insertions, 1 deletions
diff --git a/ext/intl/common/common_date.cpp b/ext/intl/common/common_date.cpp index 51141c17c7..7c589bbec2 100644 --- a/ext/intl/common/common_date.cpp +++ b/ext/intl/common/common_date.cpp @@ -119,6 +119,8 @@ U_CFUNC int intl_datetime_decompose(zval *z, double *millis, TimeZone **tz, } if (millis) { + php_date_obj *datetime; + ZVAL_STRING(&zfuncname, "getTimestamp"); if (call_user_function(NULL, z, &zfuncname, &retval, 0, NULL) != SUCCESS || Z_TYPE(retval) != IS_LONG) { @@ -131,7 +133,8 @@ U_CFUNC int intl_datetime_decompose(zval *z, double *millis, TimeZone **tz, return FAILURE; } - *millis = U_MILLIS_PER_SECOND * (double)Z_LVAL(retval); + datetime = Z_PHPDATE_P(z); + *millis = U_MILLIS_PER_SECOND * ((double)Z_LVAL(retval) + datetime->time->f); zval_ptr_dtor(&zfuncname); } diff --git a/ext/intl/tests/bug74298.phpt b/ext/intl/tests/bug74298.phpt new file mode 100644 index 0000000000..0600a46b9c --- /dev/null +++ b/ext/intl/tests/bug74298.phpt @@ -0,0 +1,30 @@ +--TEST-- +Bug #74298 (IntlDateFormatter->format() doesn't return microseconds/fractions) +--SKIPIF-- +<?php if (!extension_loaded('intl')) print 'skip'; ?> +--FILE-- +<?php +var_dump((new \DateTime('2017-01-01 01:02:03.123456'))->format('Y-m-d\TH:i:s.u')); + +var_dump((new \IntlDateFormatter( + 'en-US', + \IntlDateFormatter::FULL, + \IntlDateFormatter::FULL, + 'UTC', + \IntlDateFormatter::GREGORIAN, + 'yyyy-MM-dd HH:mm:ss.SSSSSS' +))->format(new \DateTime('2017-01-01 01:02:03.123456'))); + +var_dump(datefmt_create( + 'en-US', + \IntlDateFormatter::FULL, + \IntlDateFormatter::FULL, + 'UTC', + \IntlDateFormatter::GREGORIAN, + 'yyyy-MM-dd HH:mm:ss.SSSSSS' +)->format(new \DateTime('2017-01-01 01:02:03.123456'))); +?> +--EXPECTF-- +string(26) "2017-01-01T01:02:03.123456" +string(26) "2017-01-01 01:02:03.123000" +string(26) "2017-01-01 01:02:03.123000" |