Bug #77072 [Opn]: DateInterval constructor should provide a way to construct a negative interval
| From: | requinix@php.net | Date: | Sat, 27 Oct 2018 18:41:46 +0000 |
| Subject: | Bug #77072 [Opn]: DateInterval constructor should provide a way to construct a negative interval | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-217712@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77072&edit=1
ID: 77072
Updated by: requinix@php.net
Reported by: teo8976 at gmail dot com
Summary: DateInterval constructor should provide a way to
construct a negative interval
Status: Open
Type: Bug
-Package: PHP Language Specification
+Package: Date/time related
Operating System: all
PHP Version: 7.3.0RC4
Block user comment: N
Private report: N
New Comment:
ISO 8601's syntax does not support negative intervals so PHP shouldn't either, but the
constructor could have a second $inverted=0 argument.
Previous Comments:
------------------------------------------------------------------------
[2018-10-27 17:24:01] teo8976 at gmail dot com
Description:
------------
A DateInterval object can represent negative intervals, when its $invert property equals 1.
However, there's no way (or no documented way) to construct a DateInterval object that is
inverted with the constructor.
Yoy need to do:
$interval = new DateInterval("whatever");
$interval->inverted = 1;
It's absolutely ridiculous and pathetic that there exist values that can be represented by the
class but cannot be created with the constructor.
The interval_spec should support a way to specify inverted intervals.
Any of these would be fine, it's just a matter of taste:
- prefix the interval with a "-" (minus) sign
e.g. "-P1Y3D"
- a "-" (minus) sign after the initial P
e.g. "P-1Y3D"
- some suffix at the end, for example "I" for "Inverted"
e.g. "P1Y3DN"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77072&edit=1