Bug #79305 [NEW]: DateTimeImmutable::createFromFormat() does not permit decimal point in Atom

From: Date: Tue, 25 Feb 2020 12:44:43 +0000
Subject: Bug #79305 [NEW]: DateTimeImmutable::createFromFormat() does not permit decimal point in Atom
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225718@lists.php.net to get a copy of this message
From: xedin dot unknown at gmail dot com Operating system: Linux (Debian) PHP version: Irrelevant Package: Date/time related Bug Type: Bug Bug description:DateTimeImmutable::createFromFormat() does not permit decimal point in Atom Description: ------------ DateTimeImmutable::createFromFormat() does not appear to allow timestamps in Atom (RFC 3339) format to have a decimal point for time units. RFC 3339 derives the relevant specification from ISO-8601, which states: > A decimal mark, either a comma or a dot [...] is used as a separator between the time element and its fraction Alas, when trying to parse such a timestamp, createFromFormat() returns false, which is a bug of its own (https://bugs.php.net/bug.php?id=64923). See it in action here: https://3v4l.org/OSfKR Interestingly, when creating a date from a timestamp without the decimal part, the resulting instance has the $date property set to `2019-10-10 15:32:38.000000`, which does in fact contain the decimal part. This probably means that internally, PHP does cater for fractions. Test script: --------------- $dateString = '2019-10-10T15:32:38.916Z'; $date = \DateTimeImmutable::createFromFormat(DATE_ATOM, $dateString); if (!($date instanceof \DateTimeInterface)) { throw new RangeException('Looks like PHP cannot parse decimals in time segment'); } Expected result: ---------------- No exception is thrown. Actual result: -------------- An exception is thrown, indicating that a date instance could not be produced from the timestamp. -- Edit bug report at https://bugs.php.net/bug.php?id=79305&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=79305&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=79305&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=79305&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=79305&r=needscript Try newer version: https://bugs.php.net/fix.php?id=79305&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=79305&r=support Expected behavior: https://bugs.php.net/fix.php?id=79305&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=79305&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=79305&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=79305&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=79305&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=79305&r=dst IIS Stability: https://bugs.php.net/fix.php?id=79305&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=79305&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=79305&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=79305&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=79305&r=mysqlcfg

« previous php.bugs (#225718) next »