Skip to content

Commit 4ee6b52

Browse files
committed
Merge branch 'PHP-7.1'
2 parents ebdbebe + 1ce355a commit 4ee6b52

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

ext/intl/common/common_date.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ U_CFUNC int intl_datetime_decompose(zval *z, double *millis, TimeZone **tz,
119119
}
120120

121121
if (millis) {
122+
php_date_obj *datetime;
123+
122124
ZVAL_STRING(&zfuncname, "getTimestamp");
123125
if (call_user_function(NULL, z, &zfuncname, &retval, 0, NULL)
124126
!= SUCCESS || Z_TYPE(retval) != IS_LONG) {
@@ -131,7 +133,8 @@ U_CFUNC int intl_datetime_decompose(zval *z, double *millis, TimeZone **tz,
131133
return FAILURE;
132134
}
133135

134-
*millis = U_MILLIS_PER_SECOND * (double)Z_LVAL(retval);
136+
datetime = Z_PHPDATE_P(z);
137+
*millis = U_MILLIS_PER_SECOND * ((double)Z_LVAL(retval) + datetime->time->f);
135138
zval_ptr_dtor(&zfuncname);
136139
}
137140

ext/intl/tests/bug74298.phpt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
Bug #74298 (IntlDateFormatter->format() doesn't return microseconds/fractions)
3+
--SKIPIF--
4+
<?php if (!extension_loaded('intl')) print 'skip'; ?>
5+
--FILE--
6+
<?php
7+
var_dump((new \DateTime('2017-01-01 01:02:03.123456'))->format('Y-m-d\TH:i:s.u'));
8+
9+
var_dump((new \IntlDateFormatter(
10+
'en-US',
11+
\IntlDateFormatter::FULL,
12+
\IntlDateFormatter::FULL,
13+
'UTC',
14+
\IntlDateFormatter::GREGORIAN,
15+
'yyyy-MM-dd HH:mm:ss.SSSSSS'
16+
))->format(new \DateTime('2017-01-01 01:02:03.123456')));
17+
18+
var_dump(datefmt_create(
19+
'en-US',
20+
\IntlDateFormatter::FULL,
21+
\IntlDateFormatter::FULL,
22+
'UTC',
23+
\IntlDateFormatter::GREGORIAN,
24+
'yyyy-MM-dd HH:mm:ss.SSSSSS'
25+
)->format(new \DateTime('2017-01-01 01:02:03.123456')));
26+
?>
27+
--EXPECTF--
28+
string(26) "2017-01-01T01:02:03.123456"
29+
string(26) "2017-01-01 01:02:03.123000"
30+
string(26) "2017-01-01 01:02:03.123000"

0 commit comments

Comments
 (0)