Doc #54139 [Opn->Csd]: All date acceptance functions should cross-reference checkdate()
| From: | aharvey@php.net | Date: | Thu, 10 Mar 2011 07:13:21 +0000 |
| Subject: | Doc #54139 [Opn->Csd]: All date acceptance functions should cross-reference checkdate() | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-6061@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=54139&edit=1
ID: 54139
Updated by: aharvey@php.net
Reported by: ryan_a_martin at yahoo dot com
Summary: All date acceptance functions should cross-reference
checkdate()
-Status: Open
+Status: Closed
Type: Documentation Problem
Package: Documentation problem
Operating System: N/A
PHP Version: 5.2
-Assigned To:
+Assigned To: aharvey
Block user comment: N
Private report: N
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
Previous Comments:
------------------------------------------------------------------------
[2011-03-10 08:13:09] aharvey@php.net
Automatic comment from SVN on behalf of aharvey
Revision: http://svn.php.net/viewvc/?view=revision&revision=309064
Log: Fix doc bug #54139 (All date acceptance functions should
cross-reference
checkdate()) by cross referencing checkdate().
------------------------------------------------------------------------
[2011-03-02 16:27:28] ryan_a_martin at yahoo dot com
That's good news, but our shop is still running PHP 5.2. Also, I'm not
looking for a code change here, just some additional hyperlinks between
related functions that are not currently present.
------------------------------------------------------------------------
[2011-03-02 15:58:51] derick@php.net
FYI, later versions of PHP 5.3 do add a warning:
derick@whisky:~$ php
<?php
print_r(date_parse('2009-02-30'));
?>
Array
(
[year] => 2009
[month] => 2
[day] => 30
[hour] =>
[minute] =>
[second] =>
[fraction] =>
[warning_count] => 1
[warnings] => Array
(
[11] => The parsed date was invalid
)
[error_count] => 0
[errors] => Array
(
)
[is_localtime] =>
)
derick@whisky:~$ php -v
PHP 5.3.6-dev (cli) (built: Feb 2 2011 11:15:39) (DEBUG)
------------------------------------------------------------------------
[2011-03-02 15:56:40] ryan_a_martin at yahoo dot com
Test script was invalid:
----------
<?php
print_r(date_parse('2009-02-30'));
echo strtotime('2010-11-31');
?>
------------------------------------------------------------------------
[2011-03-02 15:54:58] ryan_a_martin at yahoo dot com
Description:
------------
Since PHP functions like strtotime, mktime, and date_parse do not catch
well-formatted but invalid dates like 2009-02-30 and 2010-11-31, it is
necessary to use checkdate() to catch them. All documentation pages that
document functions intended for accepting Gregorian dates should list
checkdate() in their "See Also" sections.
Test script:
---------------
print_r(date_parse('2009-02-30'));
print_r(strtotime('2010-11-31'));
Expected result:
----------------
For date_parse, error_count > 0 and an error thrown. For strtotime, an
error thrown, not a UNIX timestamp. Since this does not happen, we need
the documentation to make clear that these functions do not validate
Gregorian dates, and that a call to checkdate() is required to catch
such dates.
Actual result:
--------------
Array ( [year] => 2009 [month] => 2 [day] => 30 [hour] => [minute] =>
[second] => [fraction] => [warning_count] => 0 [warnings] => Array ( )
[error_count] => 0 [errors] => Array ( ) [is_localtime] => ) 1291179600
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=54139&edit=1