Nextras\Forms\Controls\DateTimePickerPrototype::getValue PHP Метод

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

public getValue ( ) : Nette\Utils\DateTime | null
Результат Nette\Utils\DateTime | null
    public function getValue()
    {
        if ($this->value instanceof DateTime) {
            // clone
            return Nette\Utils\DateTime::from($this->value);
        } elseif (is_int($this->value)) {
            // timestamp
            return Nette\Utils\DateTime::from($this->value);
        } elseif (empty($this->value)) {
            return null;
        } elseif (is_string($this->value)) {
            $parsers = $this->parsers;
            $parsers[] = $this->getDefaultParser();
            foreach ($parsers as $parser) {
                $value = $parser($this->value);
                if ($value instanceof DateTime) {
                    return $value;
                }
            }
            try {
                // DateTime constructor throws Exception when invalid input given
                return Nette\Utils\DateTime::from($this->value);
            } catch (\Exception $e) {
                return null;
            }
        }
        return null;
    }