. */ /** * Doctrine_Validator_Time * * @package Doctrine * @subpackage Validator * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link www.phpdoctrine.org * @since 1.0 * @version $Revision: 3884 $ * @author Mark Pearson */ class Doctrine_Validator_Time { /** * checks if given value is a valid time * * @param mixed $value * @return boolean */ public function validate($value) { if ($value === null) { return true; } $e = explode(':', $value); if (count($e) !== 3) { return false; } if (!preg_match('/^ *[0-9]{2}:[0-9]{2}:[0-9]{2} *$/', $value)) { return false; } $hr = intval($e[0], 10); $min = intval($e[1], 10); $sec = intval($e[2], 10); return $hr >= 0 && $hr <= 23 && $min >= 0 && $min <= 59 && $sec >= 0 && $sec <= 59; } }