Nextras\Forms\Controls\DateTimePicker::getDefaultParser PHP Method

getDefaultParser() protected method

protected getDefaultParser ( )
    protected function getDefaultParser()
    {
        return function ($value) {
            if (!preg_match('#^(?P<dd>\\d{1,2})[. -] *(?P<mm>\\d{1,2})(?:[. -] *(?P<yyyy>\\d{4})?)?(?: *[ @-] *(?P<hh>\\d{1,2})[:.](?P<ii>\\d{1,2})(?:[:.](?P<ss>\\d{1,2}))?)?$#', $value, $matches)) {
                return null;
            }
            $dd = $matches['dd'];
            $mm = $matches['mm'];
            $yyyy = isset($matches['yyyy']) ? $matches['yyyy'] : date('Y');
            $hh = isset($matches['hh']) ? $matches['hh'] : 0;
            $ii = isset($matches['ii']) ? $matches['ii'] : 0;
            $ss = isset($matches['ss']) ? $matches['ss'] : 0;
            if (!($hh >= 0 && $hh < 24 && $ii >= 0 && $ii <= 59 && $ss >= 0 && $ss <= 59)) {
                $hh = $ii = $ss = 0;
            }
            if (!checkdate($mm, $dd, $yyyy)) {
                return null;
            }
            $value = new Nette\Utils\DateTime();
            $value->setDate($yyyy, $mm, $dd);
            $value->setTime($hh, $ii, $ss);
            return $value;
        };
    }
DateTimePicker