php.net |  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: remi@php.net Assigned: bd808 (profile)
Status: Closed Package: yaml (PECL)
PHP Version: 5.6.19RC1 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: remi@php.net
New email:
PHP Version: OS:

 

 [2016-03-01 13:23 UTC] remi@php.net
Description:
------------
Since 5.6.19RC1 and 7.0.4RC1 the test suite fails:

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

This is related to fix for https://bugs.php.net/71525

Quoting Derick:

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

Input:
  "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.




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-03-01 13:26 UTC] remi@php.net
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] bd808@php.net
-Assigned To: +Assigned To: bd808
 [2016-06-04 19:34 UTC] bd808@php.net
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] bd808@php.net
-Status: Assigned +Status: Closed
 [2016-06-04 23:07 UTC] bd808@php.net
Fixed for PHP5 in release 1.3.0b1.

The date formatting used in the YAML serialization follows the spec from http://yaml.org/type/timestamp.html and https://www.w3.org/TR/NOTE-datetime.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 13:01:30 2024 UTC