Bug #74511 [NEW]: Cannot construct a \DateTime from a valid format ("Y-\WW")
From: jack dot peterson at gmail dot com
Operating system: Ubuntu 16.04
PHP version: 7.1.4
Package: Date/time related
Bug Type: Bug
Bug description:Cannot construct a \DateTime from a valid format ("Y-\WW")
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 bug report at https://bugs.php.net/bug.php?id=74511&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74511&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74511&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74511&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=74511&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=74511&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=74511&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=74511&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=74511&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=74511&r=support
Expected behavior: https://bugs.php.net/fix.php?id=74511&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=74511&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=74511&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=74511&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74511&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=74511&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=74511&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=74511&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74511&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=74511&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=74511&r=mysqlcfg
Thread (6 messages)
- jack dot peterson at gmail dot com