protected function isParsableImpl(&$value) {
        if (!parent::isParsableImpl($value)) {
            return FALSE;
        }

        $minDateLength = 10; // at least: day[1] + separator + month[1] + separator + year[2] + delimiter(space) + hour[1] + separator + minute[1]
        if (strlen($value) < $minDateLength) {
            return FALSE;
        }

        // do not use class style. We do not need an exception to be thrown
        $info = date_parse($value);
        return ($info !== FALSE)
            // errors
            && (count($info['warnings']) == 0)
            && ($info['error_count'] == 0)
            && (count($info['errors']) == 0)
            // date
            && ($info['year'] !== FALSE)
            && ($info['month'] !== FALSE)
            && ($info['day'] !== FALSE)
            // time
            && ($info['hour'] !== FALSE)
            && ($info['minute'] !== FALSE)
            && ($info['second'] !== FALSE)
            && ($info['fraction'] !== FALSE);
    }
Esempio n. 2
0
 protected function isParsableImpl(&$value)
 {
     if (!parent::isParsableImpl($value)) {
         return FALSE;
     }
     // do not use class style. We do not need an exception to be thrown
     $info = date_parse($value);
     return $info !== FALSE && $info['year'] !== FALSE && $info['month'] !== FALSE && $info['day'] !== FALSE && $info['hour'] !== FALSE && $info['minute'] !== FALSE && $info['second'] !== FALSE;
 }