Bug #65548 [Opn->Csd]: Comparison for DateTimeImmutable doesn't work
| From: | nikic@php.net | Date: | Thu, 12 Sep 2013 13:15:33 +0000 |
| Subject: | Bug #65548 [Opn->Csd]: Comparison for DateTimeImmutable doesn't work | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-181543@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65548&edit=1
ID: 65548
Updated by: nikic@php.net
Reported by: mail at roland-ramthun dot de
Summary: Comparison for DateTimeImmutable doesn't work
-Status: Open
+Status: Closed
Type: Bug
Package: Date/time related
Operating System: Linux
PHP Version: 5.5.3
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of bsitnikovski@sugarcrm.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=d7f5f1ef35c32d6943cd76a3c51752e8d64c5e5e
Log: Fix bug #65548: Comparison for DateTimeImmutable doesn't work
Previous Comments:
------------------------------------------------------------------------
[2013-08-27 23:44:59] cmbecker69 at gmx dot de
It seems that the comparison operators are not overloaded for
DateTimeImmutable objects. Apparently they show the same behavior
as for arbitrary user defined classes.
If my assumption is correct, instead of adding a special treatment
for the comparison operators wrt. DateTimeImmutable objects, it
might be considered to add a magic method __compare(). However,
I'm not sure, if this fits well with type juggling.
------------------------------------------------------------------------
[2013-08-25 14:03:21] mail at roland-ramthun dot de
Description:
------------
Comparison for DateTimeImmutable doesn't work. The same example with DateTime objects works.
Test script:
---------------
$a = new DateTimeImmutable('today');
$b = new DateTimeImmutable('tomorrow');
if ($a < $b) {
print("yay");
}
Expected result:
----------------
yay
Actual result:
--------------
no output
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65548&edit=1