Bug #75642 [Ver]: Wrap around behaviour for microseconds is not working

From: Date: Fri, 09 Mar 2018 15:06:06 +0000
Subject: Bug #75642 [Ver]: Wrap around behaviour for microseconds is not working
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-214254@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75642&edit=1 ID: 75642 Updated by: requinix@php.net Reported by: marcospassos dot com at gmail dot com Summary: Wrap around behaviour for microseconds is not working Status: Verified Type: Bug Package: Date/time related Operating System: OSX PHP Version: 7.2.0 Block user comment: N Private report: N New Comment: Microseconds are actually their own distinct integer. Off by one error. https://github.com/php/php-src/blob/PHP-7.2.0/ext/date/lib/tm2unixtime.c#L42 Additionally it's only able to over-/underflow the seconds by a change of 2. https://3v4l.org/4Ra66 Previous Comments: ------------------------------------------------------------------------ [2018-03-09 12:06:12] cmb@php.net > pretty sure the sad float precision problem Apparently[1]. However, 2017-12-31 23:59:59.1000000 is wrong nonetheless. [1] <https://3v4l.org/e3utY> ------------------------------------------------------------------------ [2018-01-21 19:12:30] marcospassos dot com at gmail dot com Any update about this issue? ------------------------------------------------------------------------ [2017-12-06 22:26:26] spam2 at rhsoft dot net pretty sure the sad float precision problem which makes me wonder why it's called computer and not guesser ------------------------------------------------------------------------ [2017-12-06 22:12:12] marcospassos dot com at gmail dot com Expected result: ---------------- 2017-12-31 23:59:59.999999 2018-01-01 00:00:00.000000 ------------------------------------------------------------------------ [2017-12-06 22:11:26] marcospassos dot com at gmail dot com Description: ------------ When adding 1 microsecond to 999999 does not increment the seconds part. Test script: --------------- // https://3v4l.org/Wl6if $date = new \DateTime('2017-12-31 23:59:59.999999'); echo $date->format('Y-m-d H:i:s.u'); echo "\n"; echo $date->modify('+1 microsecond')->format('Y-m-d H:i:s.u'); Expected result: ---------------- 2017-12-31 23:59:59.999999 2016-01-01 00:00:00.000000 Actual result: -------------- 2017-12-31 23:59:59.999999 2017-12-31 23:59:59.1000000 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75642&edit=1

« previous php.bugs (#214254) next »