35 lines
746 B
PHP
35 lines
746 B
PHP
<?php
|
|
|
|
require_once 'abstract.php';
|
|
|
|
/**
|
|
* Проверка формата времени
|
|
*/
|
|
class Rule_Time extends Rule_Abstract
|
|
{
|
|
private $split = ":";
|
|
|
|
public function getErrorMsg()
|
|
{
|
|
return "Неверный формат времени";
|
|
}
|
|
|
|
static function checktime($hour, $minute)
|
|
{
|
|
if ($hour > -1 && $hour < 24 && $minute > -1 && $minute < 60) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
public function isValid(Collection $container, $status = null)
|
|
{
|
|
$tmp = explode($this->split, $container->get($this->field), 2);
|
|
if ($tmp) {
|
|
if (self::checktime ($tmp[0], $tmp[1])) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|