patterns[] = $this->defaultFormat; $this->dateValidator = new DateTimeValidator($this->patterns); $this->addValidator($this->dateValidator); } /** * Validate filtered date/time strings * * Expects one or more valid formats being set in $this->patterns. Sets element value as Unix timestamp * if the input is considered valid. Utilizes DateTimeFactory to ensure time zone awareness. * * @param string $value * @param mixed $context * @return bool */ public function isValid($value, $context = null) { // Overwrite the internal validator to use if (!parent::isValid($value, $context)) { return false; } $pattern = $this->dateValidator->getValidPattern(); if (!$pattern) { $this->setValue($value); return true; } $this->setValue(DateTimeFactory::parse($value, $pattern)->getTimestamp()); return true; } public function enableJsPicker() { $this->jspicker = true; } public function disableJsPicker() { $this->jspicker = false; } }