PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Validate » Validate » Bug #6129

Incorrect time validation

Details

Submitted2005-12-02 08:41 UTC
Fromjonathanmartens at gmx dot net
Assignedtoggg
StatusBogus
PackageValidate
PHP Version5.0.4
OSWin XP SP2
Roadmaps(Not assigned)

Comments

[2005-12-02 08:41 UTC] jonathanmartens at gmx dot net

Description:
------------
The Validate::date function is able to validate times, however it is not strict enough (for 24h time representation, I don't know about the am/pm representation, but I think there teh failure is analog):

If the time is 24:00h it ik OK for the date to be valid, however when the date is in the range of 24:01h-24:59h it also passes, but to my best knowledge it should not as normally this is represented by 0:01-0:59.

Test script:
---------------
Validate::date('24:59', array('format' => '%H:%i'));

Expected result:
----------------
The test script should retrun FALSE but returns TRUE.

Actual result:
--------------
Suggested fix:

Add the following lines analogue to the option for the date:

if (isset($hour) && isset($t)) {
if ( ( $hour == 24 ) && ( $t != 0 ) ) {
return false;
}
}

It the problem also exists in the am/pm representation it will be a bit more complex.