1: <?php
2: /**
3: * Pry Framework
4: *
5: * LICENSE
6: *
7: * This source file is subject to the new BSD license that is bundled
8: * with this package in the file LICENSE.txt.
9: *
10: * @version $Revision: 276 $
11: */
12:
13: /**
14: * Validateur d'heure format sql.
15: * @category Pry
16: * @package Validate
17: * @subpackage Validate_Validator
18: * @version 1.0.0
19: * @author Olivier ROGER <oroger.fr>
20: *
21: */
22: class Validate_Validator_Time extends Validate_Abstract
23: {
24: /**
25: * Constructeur
26: * @access public
27: */
28: public function __construct()
29: {
30: $this->errorMsg = "n'est pas une heure valide";
31: }
32:
33: /**
34: * Validation
35: *
36: * @param string $string Elément à valider
37: * @return boolean
38: */
39: public function isValid($string)
40: {
41: $string = $this->cleanString((string)$string);
42: $pattern = '`^([0-9]{2}:[0-9]{2}:[0-9]{2})$`';
43: if(preg_match($pattern,$string))
44: {
45: list($heure,$min,$sec) = explode(':',$string);
46: if(($heure>=0 && $heure<24) && ($min>=0 && $min<60) && ($sec>=0 && $sec<60))
47: return true;
48: }
49: return false;
50: }
51: }
52: ?>