PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

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.