Bug #76785 [Com]: DateTime construction with a negative year argument shows different behaviours
| From: | bjoern dot fischer at dezem dot de | Date: | Wed, 28 Nov 2018 14:19:15 +0000 |
| Subject: | Bug #76785 [Com]: DateTime construction with a negative year argument shows different behaviours | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-218177@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
Comment by: bjoern dot fischer at dezem dot de
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
Block user comment: N
Private report: N
New Comment:
We are affected by this issue too.
It can be easily reproduced here:
https://3v4l.org/LY6FJ
Previous Comments:
------------------------------------------------------------------------
[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