Doc #70154 [Ver->Csd]: date_parse() not returning false for missing time components

[email protected] Thu, 02 Jun 2022 09:41:38 +0000
Newsgroups php.doc.bugs
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=70154&edit=1

 ID:                 70154
 Updated by:         [email protected]
 Reported by:        abodera at gmail dot com
 Summary:            date_parse() not returning false for missing time
                     components
-Status:             Verified
+Status:             Closed
 Type:               Documentation Problem
 Package:            Date/time related
 Operating System:   Linux
 PHP Version:        5.6.11
 Block user comment: N
 Private report:     N

 New Comment:

Automatic comment on behalf of derickr
Revision: https://github.com/php/doc-en/commit/cf25abe5d089fc9486b98576671f8b90b357cf31
Log: Fixed bug #70154: date_parse() not returning false for missing time components


Previous Comments:
------------------------------------------------------------------------
[2021-11-23 11:33:58] [email protected]

Given the long standing behavior which exists since the function
has been introduced, changing the behavior would be a pretty big
BC break. And given there has been no more traction on this ticket
for more than six years, I'm changing it to documentation issue.

------------------------------------------------------------------------
[2015-07-27 16:48:52] [email protected]

I can confirm the different behavior.

It occurs to me that this might be an issue with
TIMELIB_UNHAVE_TIME[1], where h, i, s and f might have to be set
to TIMELIB_UNSET.

[1] <https://github.com/derickr/timelib/blob/2015.01/parse_date.re#L116>

------------------------------------------------------------------------
[2015-07-27 14:05:27] abodera at gmail dot com

Description:
------------
date_parse() is expected to return false for missing values.

For example: 

    date_parse('1st Aug')['year'] === false;

As soon as you provide day of week, the hour, minute, second components magically become 0 (as in 00:00:00) even though they do not exist:

    date_parse('Sat 1st Aug')['hour'] === 0; // expected: false
    date_parse('Sat 1st Aug')['minute'] === 0; // expected: false
    date_parse('Sat 1st Aug')['second'] === 0; // expected: false


See: http://3v4l.org/HvND2

Test script:
---------------
<?php

print_r(date_parse('Sat 1st Aug'));



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=70154&edit=1