Bug #52430 [Opn->Ver]: date_parse parse 24:xx:xx as valid time
| From: | dtajchreber@php.net | Date: | Mon, 26 Jul 2010 06:00:54 +0000 |
| Subject: | Bug #52430 [Opn->Ver]: date_parse parse 24:xx:xx as valid time | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-152781@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52430&edit=1
ID: 52430
Updated by: dtajchreber@php.net
Reported by: pulzarraider at gmail dot com
Summary: date_parse parse 24:xx:xx as valid time
-Status: Open
+Status: Verified
Type: Bug
Package: Date/time related
Operating System: Win 7
PHP Version: 5.3.3
-Assigned To:
+Assigned To: derick
Block user comment: N
New Comment:
According to ISO 8601:
"As this International Standard is based on the 24-hour timekeeping
system that
is now in common use, hours are represented by two digits from [00] to
[24],
minutes are represented by two digits from [00] to [59], and seconds are
represented by two digits from [00] to [60]. For most purposes, times
will be
represented by four digits [hhmm].
The representation of the hour by [24] is only allowed to indicate
midnight, see
5.3.2.
The representation of the second by [60] is only allowed to indicate the
positive leap second or a time-point within that
second.
...
Midnight will normally be represented as [0000] or [2400].
...
The end of one day [2400] coincides with [0000] at the start of the next
day,
e.g. 2400 on 1985 April 12 is the same as 0000 on 1985 April 13. If
there is no
association with a date or a time-interval both a) and b) represent the
same
clock time in the 24-hour timekeeping system."
So 2400 isn't technically wrong but it doesn't look like the regular
expressions
in parse_date.re are context specific right now (eg. 24 only if followed
by 00
so it allows 2401 through 2459). This looks like a pretty big rewrite.
Assigning
to Derick.
Previous Comments:
------------------------------------------------------------------------
[2010-07-24 21:20:26] pulzarraider at gmail dot com
Description:
------------
In the 24-hour time notation, the day begins at midnight, 00:00, and the
last minute of the day begins at 23:59.
Date_parse function returns no warning and no error when any time
starting with hour "24" is used as parameter. But some error is
expected, because 2010-1-1 24:59:59 is NOT valid date.
This can cause serious errors in scripts that use date_parse for
validating dateTime strings.
Test script:
---------------
<?php
date_parse('2010-1-1 24:00:00');
//This is invalid date, but date_parse returns no error and warning
//Expected: error "Unexpected character"
//date_parse('2010-1-1 24:59:59');
//This is also invalid date, but date_parse returns no error and
warning
//Expected: error "Unexpected character"
?>
Expected result:
----------------
Array (
[year] => 2010
[month] => 1
[day] => 1
[hour] => 0
[minute] => 0
[second] => 0
[fraction] => 0
[warning_count] => 0
[warnings] => Array ( )
[error_count] => 1
[errors] => Array ([9]=>'Unexpected character')
[is_localtime] =>false
)
Actual result:
--------------
Array (
[year] => 2010
[month] => 1
[day] => 1
[hour] => 24 <===== wrong
[minute] => 0
[second] => 0
[fraction] => 0
[warning_count] => 0
[warnings] => Array ( )
[error_count] => 0 <===== wrong
[errors] => Array ( ) <===== wrong
[is_localtime] =>false
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52430&edit=1