Controller_Validator_Basic::rule_iso_time PHP Метод

rule_iso_time() публичный Метод

Requires a complete hour:minute:second time with the optional ':' separators. Checks for hh:mm[[:ss][.**..] where * = microseconds Also checks for valid # of hours, mins, secs
public rule_iso_time ( $a )
    public function rule_iso_time($a)
    {
        $pattern = "/^([0-9]{2}):([0-9]{2})(?::([0-9]{2})(?:(?:\\.[0-9]{1,}))?)?\$/";
        $msg = 'Must be a valid ISO time';
        if (preg_match($pattern, $a, $matches)) {
            if ($matches[1] > 24) {
                return $this->fail($msg);
            }
            if ($matches[2] > 59) {
                return $this->fail($msg);
            }
            if (isset($matches[3]) && $matches[3] > 59) {
                return $this->fail($msg);
            }
        } else {
            return $this->fail($msg);
        }
    }