|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71696 Bad datetime management
Submitted: 2016-03-01 13:23 UTC Modified: 2016-06-04 23:07 UTC
From: Assigned: bd808 (profile)
Status: Closed Package: yaml (PECL)
PHP Version: 5.6.19RC1 OS:
Private report: No CVE-ID: None
 [2016-03-01 13:23 UTC]
Since 5.6.19RC1 and 7.0.4RC1 the test suite fails:

TEST 11/62 [tests/yaml_002.phpt]
010+ bool(false)
010- bool(true)
FAIL yaml - emit -> parse roundtrip with datetime [tests/yaml_002.phpt] 

This is related to fix for

Quoting Derick:

I had a look at this again, and the YAML parser simply doesn't encode 
the fractions properly.

  "canonical" => new DateTime("2001-12-15T02:59:43.1Z"),

YAML created:
  canonical: 2001-12-15T02:59:43+0000

see it misses the ".1" from the original date string

Of course, when you then convert it back to DateTime, it still misses 
the .1:

  'canonical' => string(24) "2001-12-15T02:59:43+0000"

Before this bug fix, the fraction wasn't taking into account when 
comparing. F.e., this would compare as true:

$a = new DateTime("2001-12-15T02:59:43.5Z");
$b = new DateTime("2001-12-15T02:59:43.7Z");

var_dump( $a == $b );

After the bug fix, it (correctly) no longer does that.
So the YAML extension's tests are wrong, or, they need to implement 
support for fractions.

The YAML extension also loses the 'Europe/London' and 'Z' timezone 
information, as in the created YAML just does +0000 and -0500.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-03-01 13:26 UTC]
Both version 1.2.0 (PHP 5.6.19RC1) and 2.0.0RC7 (PHP 7.0.4RC1) are affected.
 [2016-06-04 19:34 UTC]
-Assigned To: +Assigned To: bd808
 [2016-06-04 19:34 UTC]
This have been fixed for PHP7 in the php7 git branch. I'll work on a backport for PHP5 in master.
 [2016-06-04 23:07 UTC]
-Status: Assigned +Status: Closed
 [2016-06-04 23:07 UTC]
Fixed for PHP5 in release 1.3.0b1.

The date formatting used in the YAML serialization follows the spec from and
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Dec 06 09:03:34 2021 UTC