Bug #74511 [Opn->Nab]: Cannot construct a \DateTime from a valid format ("Y-\WW")
| From: | requinix@php.net | Date: | Fri, 28 Apr 2017 17:53:48 +0000 |
| Subject: | Bug #74511 [Opn->Nab]: Cannot construct a \DateTime from a valid format ("Y-\WW") | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-208848@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74511&edit=1
ID: 74511
Updated by: requinix@php.net
Reported by: jack dot peterson at gmail dot com
Summary: Cannot construct a \DateTime from a valid format
("Y-\WW")
-Status: Open
+Status: Not a bug
Type: Bug
Package: Date/time related
Operating System: Ubuntu 16.04
PHP Version: 7.1.4
Block user comment: N
Private report: N
New Comment:
DateTime represents an actual date. What date would 2017-W01 represent?
Previous Comments:
------------------------------------------------------------------------
[2017-04-28 17:49:53] jack dot peterson at gmail dot com
Description:
------------
Given the format, 'Y-\WW', one should be able to construct a date such as 2017-W01 or
2017-W1 as a valid date where W is a number from 0-52 as documented for Date.
The expected behavior here would be to create a valid date w/ the next least-significant values to
be zeroed out. Current behavior is that one cannot construct a valid \DateTime from the requested
format.
Test script:
---------------
public function testCanCreateDateFromFormat() {
$format = 'Y-\WW';
$date = '2017-W01';
$obj = \DateTime::createFromFormat($format, $date);
$this->assertInstanceOf(\DateTime::class, $obj);
}
testCanCreateDateFromFormat
Failed asserting that false is an instance of class "DateTime".
Expected result:
----------------
\DateTime::createFromFormat should return an instance of \DateTime
Actual result:
--------------
\DateTime::createFromFormat returns false in this scenario.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74511&edit=1