Bug #76785 [Opn]: DateTime construction with a negative year argument shows different behaviours
| From: | girgias@php.net | Date: | Mon, 20 Jan 2020 17:35:46 +0000 |
| Subject: | Bug #76785 [Opn]: DateTime construction with a negative year argument shows different behaviours | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-225011@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76785&edit=1
ID: 76785
Updated by: girgias@php.net
Reported by: thijs at tsjeng dot nl
Summary: DateTime construction with a negative year argument
shows different behaviours
Status: Open
Type: Bug
Package: Date/time related
PHP Version: Irrelevant
-Assigned To:
+Assigned To: derick
Block user comment: N
Private report: N
New Comment:
This maybe should be reclassified as a Feature request, leaving Derick to decide about it.
Previous Comments:
------------------------------------------------------------------------
[2018-11-28 14:19:15] bjoern dot fischer at dezem dot de
We are affected by this issue too.
It can be easily reproduced here:
https://3v4l.org/LY6FJ
------------------------------------------------------------------------
[2018-08-23 17:10:15] requinix@php.net
Fortunately 'U' already supports signed numbers so extending that to 'Y'
shouldn't be difficult.
------------------------------------------------------------------------
[2018-08-23 15:29:40] thijs at tsjeng dot nl
Description:
------------
DateTime object instantiation with negative input string via
'createFromFormat' and same argument just as construction argument display weird
behaviour.
Test script:
---------------
var_dump(DateTime::createFromFormat('Y-m-d', '0045-01-01')); // works
var_dump(DateTime::createFromFormat('Y-m-d', '-0045-01-01')); // false
var_dump(DateTime::createFromFormat('-Y-m-d', '-0045-01-01')); // works, but
year is positive instead of negative
var_dump(new DateTime('0045-01-01')); // works
var_dump(new DateTime('-0045-01-01')); // works
var_dump(new DateTime('0045/01/01')); // works
var_dump(new DateTime('-0045/01/01')); // exception
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76785&edit=1