Bug #54495 [Opn->Bgs]: Empty DateInterval has wrong days
| From: | danielc@php.net | Date: | Mon, 21 Nov 2011 02:50:40 +0000 |
| Subject: | Bug #54495 [Opn->Bgs]: Empty DateInterval has wrong days | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-165387@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=54495&edit=1
ID: 54495
Updated by: danielc@php.net
Reported by: bandy dot chris at gmail dot com
Summary: Empty DateInterval has wrong days
-Status: Open
+Status: Bogus
Type: Bug
Package: Date/time related
Operating System: Linux, x86_64
PHP Version: 5.3.6
-Assigned To:
+Assigned To: danielc
Block user comment: N
Private report: N
New Comment:
"days" is a calculated field expressing how many days are between two compared dates. It
is never set when instantiating a new date interval. The "d" property contains the number
of days specified in the interval format. Everything is operating as expected.
Previous Comments:
------------------------------------------------------------------------
[2011-04-08 17:34:08] bandy dot chris at gmail dot com
Description:
------------
A DateInterval created with a period that spans zero days reports $days = FALSE rather than 0.
A DateInterval created by subtracting two DateTimes reports $days = 0 correctly.
Test script:
---------------
<?php
// Period of zero days, zero seconds
// $days = FALSE
print_r(new DateInterval('P0Y'));
// Difference of identical timestamps
// $days = 0
print_r(date_diff(new DateTime('@1289997296'), new DateTime('@1289997296')));
Expected result:
----------------
DateInterval Object
(
[y] => 0
[m] => 0
[d] => 0
[h] => 0
[i] => 0
[s] => 0
[invert] => 0
[days] => 0
)
DateInterval Object
(
[y] => 0
[m] => 0
[d] => 0
[h] => 0
[i] => 0
[s] => 0
[invert] => 0
[days] => 0
)
Actual result:
--------------
DateInterval Object
(
[y] => 0
[m] => 0
[d] => 0
[h] => 0
[i] => 0
[s] => 0
[invert] => 0
[days] =>
)
DateInterval Object
(
[y] => 0
[m] => 0
[d] => 0
[h] => 0
[i] => 0
[s] => 0
[invert] => 0
[days] => 0
)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=54495&edit=1