Skip to content

Commit

Permalink
fix bug #75222 DateInterval microseconds property always 0
Browse files Browse the repository at this point in the history
  • Loading branch information
jhdxr authored and krakjoe committed Sep 27, 2017
1 parent b0950ff commit 7deb561
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ PHP NEWS
. Fixed bug #75220 (Segfault when calling is_callable on parent).
(andrewnester)

- Date:
. Fixed bug #75222 (DateInterval microseconds property always 0). (jhdxr)

- litespeed:
. Fixed bug #75248 (Binary directory doesn't get created when building
only litespeed SAPI). (petk)
Expand Down
2 changes: 1 addition & 1 deletion ext/date/php_date.c
Original file line number Diff line number Diff line change
Expand Up @@ -4165,7 +4165,7 @@ zval *date_interval_read_property(zval *object, zval *member, int type, void **c
GET_VALUE_FROM_STRUCT(i, "i");
GET_VALUE_FROM_STRUCT(s, "s");
if (strcmp(Z_STRVAL_P(member), "f") == 0) {
fvalue = obj->diff->us / 1000000;
fvalue = obj->diff->us / 1000000.0;
break;
}
GET_VALUE_FROM_STRUCT(invert, "invert");
Expand Down
17 changes: 17 additions & 0 deletions ext/date/tests/bug75222.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
Bug #75222 DateInterval microseconds property always 0
--FILE--
<?php

$dt1 = new \DateTimeImmutable('2017-01-01T00:00:00.000000Z');
$dt2 = new \DateTimeImmutable('2017-01-01T00:00:00.123456Z');
$diff = $dt1->diff($dt2);
//var_dump($diff);
var_dump($diff->f);
var_dump(get_object_vars($diff)['f']);
var_dump($diff->f === get_object_vars($diff)['f']);
?>
--EXPECTF--
float(0.123456)
float(0.123456)
bool(true)

0 comments on commit 7deb561

Please sign in to comment.