Bug #81106 [Com]: Regression in 8.1: add() now truncate ->f

From: Date: Fri, 04 Jun 2021 18:22:12 +0000
Subject: Bug #81106 [Com]: Regression in 8.1: add() now truncate ->f
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-234214@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81106&edit=1 ID: 81106 Comment by: kylekatarnls at gmail dot com Reported by: kylekatarnls at gmail dot com Summary: Regression in 8.1: add() now truncate ->f Status: Open Type: Bug Package: Date/time related Operating System: Ubuntu PHP Version: master-Git-2021-06-04 (Git) Block user comment: N Private report: N New Comment: For the record, it's not consistent with what happen with ->s = 78 which properly add 78 seconds in both PHP 8.0 and 8.1 Previous Comments: ------------------------------------------------------------------------ [2021-06-04 17:41:46] kylekatarnls at gmail dot com Description: ------------ An interval with ->f = 1.234 was previously understood as 1.234 second when using in DateTime::add() which sounds pretty consistent. Now it's understood as 0.234 which feels pretty unsafe. Moreover, if we dump the interval, we see ->f value is still 1.234. If ->f can now longer be >= 1, it would rather need to throw an exception rather than accepting it and be interpreted differently regarding where it's used. Test script: --------------- $dateInterval = new DateInterval('PT0S'); $dateInterval->f = 1.234; echo (new DateTimeImmutable('2000-01-01 00:00:00'))->add($dateInterval)->format('Y-m-d H:i:s.u'); Expected result: ---------------- 2000-01-01 00:00:01.234000 (What we got for PHP <= 8.0) Actual result: -------------- 2000-01-01 00:00:00.234000 (What we get now with master branch) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=81106&edit=1

« previous php.bugs (#234214) next »