/** * @param $value * @param $dataSource * @return mixed */ public function filter($value, IDataSource $dataSource) { $value = strtotime($value); $begin = strtotime('today', $value); $end = strtotime('+1 day', $begin); $dataSource->filter(['%n BETWEEN %s AND %s', $this->column->getColumn(), DateTime::from($begin), DateTime::from($end)]); }
public function setValue($value) { if ($value) { $date = DateTime::from($value); $this->day = $date->format('j'); $this->month = $date->format('n'); $this->year = $date->format('Y'); } else { $this->day = $this->month = $this->year = NULL; } }
/** * Parses the txt file and updates the cache files * * @return bool whether the file was correctly written to the disk */ public function updateCache($force = FALSE) { if (($this->_registry = $this->load(Registry::REGISTRY)) !== NULL) { $cver = $this->load(Registry::ETAG); $this->getRemoteData($cver); if ($cver == $this->_etag && $this->load(Registry::MD5) == md5($this->_sourceData) && !$force) { return TRUE; } } $this->getRemoteData(); $this->raw2csv(); $this->csv2registry(); // Save and return $expiration = \Nette\DateTime::from(time())->add(new \DateInterval('P2W')); $dependencies = [Caching\Cache::CONSTS => ['Nette\\Framework::REVISION'], Caching\Cache::EXPIRATION => $expiration]; $this->save(Registry::SOURCE, $this->sourceUrl, $dependencies); $this->save(Registry::DATA, $this->_sourceData, $dependencies); $this->save(Registry::ETAG, $this->_etag, $dependencies); $this->save(Registry::MD5, md5($this->_sourceData), $dependencies); $this->save(Registry::REGISTRY, $this->_registry, $dependencies); $this->release(); }
/** * Creates Addon entity from Nette\Database row. * * @todo Consider lazy loading for versions and tags. * * @param \Nette\Database\Table\ActiveRow * @param AddonVotes * @return Addon */ public static function fromActiveRow(ActiveRow $row, AddonVotes $addonVotes = NULL) { $addon = new static(); $addon->id = (int) $row->id; $addon->name = $row->name; $addon->composerVendor = $row->composerVendor; $addon->composerName = $row->composerName; $addon->userId = (int) $row->user->id; $addon->shortDescription = $row->shortDescription; $addon->description = $row->description; $addon->descriptionFormat = $row->descriptionFormat; $addon->defaultLicense = $row->defaultLicense; $addon->repository = $row->repository; $addon->repositoryHosting = $row->repositoryHosting; $addon->demo = $row->demo; $addon->updatedAt = $row->updatedAt ? DateTime::from($row->updatedAt) : NULL; $addon->deletedAt = $row->deletedAt; $addon->deletedBy = $row->ref('deletedBy'); $addon->type = $row->type; $addon->stars = $row->stars; foreach ($row->related('versions') as $versionRow) { $version = AddonVersion::fromActiveRow($versionRow); $version->addon = $addon; $addon->versions[$version->version] = $version; } foreach ($row->related('tags') as $tagRow) { $addon->tags[$tagRow->tag->id] = Tag::fromActiveRow($tagRow->tag); } foreach ($row->related('addons_resources') as $resourceRow) { $addon->resources[$resourceRow->type] = $resourceRow->resource; } if ($addonVotes) { $addon->votes = $addonVotes->calculatePopularity($row); } return $addon; }
function setValue($value) { if ($value instanceof DateTime) { } elseif (is_int($value)) { } elseif (empty($value)) { $rawValue = $value; $value = NULL; } elseif (is_string($value)) { $rawValue = $value; if (preg_match('#^(?P<dd>\\d{1,2})[. -] *(?P<mm>\\d{1,2})([. -] *(?P<yyyy>\\d{4})?)?$#', $value, $matches)) { $dd = $matches['dd']; $mm = $matches['mm']; $yyyy = isset($matches['yyyy']) ? $matches['yyyy'] : date('Y'); if (checkdate($mm, $dd, $yyyy)) { $value = "{$yyyy}-{$mm}-{$dd}"; } else { $value = NULL; } } } else { throw new \InvalidArgumentException(); } if ($value !== NULL) { try { $value = Nette\DateTime::from($value); } catch (\Exception $e) { $value = NULL; } } if (!isset($rawValue) && isset($value)) { $rawValue = $value->format(self::W3C_DATE_FORMAT); } $this->value = $value; $this->rawValue = $rawValue; return $this; }
/** * @param string|int|\DateTime $time * @param string $format * @return string */ public static function datetime($time, $format = NULL) { if ($time == NULL) { // intentionally == return NULL; } return date($format ?: self::$datetimeFormat, \Nette\DateTime::from($time)->format('U')); }
/** * Sets the amount of time allowed between requests before the session will be terminated. * @param string|int|DateTime time, value 0 means "until the browser is closed" * @return self */ public function setExpiration($time) { if (empty($time)) { return $this->setOptions(array('gc_maxlifetime' => self::DEFAULT_FILE_LIFETIME, 'cookie_lifetime' => 0)); } else { $time = Nette\DateTime::from($time)->format('U') - time(); return $this->setOptions(array('gc_maxlifetime' => $time, 'cookie_lifetime' => $time)); } }
/** * Normalizes result row. * @param array * @return array */ public function normalizeRow($row) { if ($this->types === NULL) { $this->types = (array) $this->supplementalDriver->getColumnTypes($this->pdoStatement); } foreach ($this->types as $key => $type) { $value = $row[$key]; if ($value === NULL || $value === FALSE || $type === IReflection::FIELD_TEXT) { } elseif ($type === IReflection::FIELD_INTEGER) { $row[$key] = is_float($tmp = $value * 1) ? $value : $tmp; } elseif ($type === IReflection::FIELD_FLOAT) { if (($pos = strpos($value, '.')) !== FALSE) { $value = rtrim(rtrim($pos === 0 ? "0{$value}" : $value, '0'), '.'); } $float = (double) $value; $row[$key] = (string) $float === $value ? $float : $value; } elseif ($type === IReflection::FIELD_BOOL) { $row[$key] = (bool) $value && $value !== 'f' && $value !== 'F'; } elseif ($type === IReflection::FIELD_DATETIME || $type === IReflection::FIELD_DATE || $type === IReflection::FIELD_TIME) { $row[$key] = new Nette\DateTime($value); } elseif ($type === IReflection::FIELD_TIME_INTERVAL) { preg_match('#^(-?)(\\d+)\\D(\\d+)\\D(\\d+)\\z#', $value, $m); $row[$key] = new \DateInterval("PT{$m['2']}H{$m['3']}M{$m['4']}S"); $row[$key]->invert = (int) (bool) $m[1]; } elseif ($type === IReflection::FIELD_UNIX_TIMESTAMP) { $row[$key] = Nette\DateTime::from($value); } } return $this->supplementalDriver->normalizeRow($row); }
/** * Sets the expiration of the section or specific variables. * @param string|int|DateTime time, value 0 means "until the browser is closed" * @param mixed optional list of variables / single variable to expire * @return SessionSection provides a fluent interface */ public function setExpiration($time, $variables = NULL) { $this->start(); if (empty($time)) { $time = NULL; $whenBrowserIsClosed = TRUE; } else { $time = Nette\DateTime::from($time)->format('U'); $max = ini_get('session.gc_maxlifetime'); if ($time - time() > $max + 3) { // bulgarian constant trigger_error("The expiration time is greater than the session expiration {$max} seconds", E_USER_NOTICE); } $whenBrowserIsClosed = FALSE; } if ($variables === NULL) { // to entire section $this->meta['']['T'] = $time; $this->meta['']['B'] = $whenBrowserIsClosed; } elseif (is_array($variables)) { // to variables foreach ($variables as $variable) { $this->meta[$variable]['T'] = $time; $this->meta[$variable]['B'] = $whenBrowserIsClosed; } } else { // to variable $this->meta[$variables]['T'] = $time; $this->meta[$variables]['B'] = $whenBrowserIsClosed; } return $this; }
/** * Date/time modification. * @param string|int|DateTime * @param string|int * @param string * @return Nette\DateTime */ public static function modifyDate($time, $delta, $unit = NULL) { return $time == NULL ? NULL : Nette\DateTime::from($time)->modify($delta . $unit); }
/** * Sends a cookie. * @param string name of the cookie * @param string value * @param string|int|DateTime expiration time, value 0 means "until the browser is closed" * @param string * @param string * @param bool * @param bool * @return self * @throws Nette\InvalidStateException if HTTP headers have been sent */ public function setCookie($name, $value, $time, $path = NULL, $domain = NULL, $secure = NULL, $httpOnly = NULL) { self::checkHeaders(); setcookie($name, $value, $time ? Nette\DateTime::from($time)->format('U') : 0, $path === NULL ? $this->cookiePath : (string) $path, $domain === NULL ? $this->cookieDomain : (string) $domain, $secure === NULL ? $this->cookieSecure : (bool) $secure, $httpOnly === NULL ? $this->cookieHttpOnly : (bool) $httpOnly); $this->removeDuplicateCookies(); return $this; }
protected function getFiles() { $ret = array(); foreach (Finder::findFiles('exception*')->in($this->logDir) as $file) { $data = explode('-', $file->getFileName()); $date = "{$data[1]}-{$data[2]}-{$data[3]} {$data[4]}:{$data[5]}:{$data[6]}"; $info = array('date' => DateTime::from($date), 'hash' => $data[7], 'link' => $file->getFileName()); $ret[$date] = $info; } ksort($ret); return array_reverse($ret); }
strtr($m[0]," \t\r\n","\x1F\x1E\x1D\x1A");});$s=Strings::indent($s,$level,$chars);$s=strtr($s,"\x1F\x1E\x1D\x1A"," \t\r\n");}return$s;}static function date($time,$format=NULL){if($time==NULL){return NULL;}if(!isset($format)){$format=self::$dateFormat;}$time=Nette\DateTime::from($time);return Strings::contains($format,'%')?strftime($format,$time->format('U')):$time->format($format);}static
/** * @param mixed * @return \DateInterval */ private function createInterval($value) { $dt = class_exists('Nette\\Utils\\DateTime') ? Nette\Utils\DateTime::from($value) : Nette\DateTime::from($value); return (new \DateTime())->diff($dt); }
public function setValue($value) { if ($value) { if (is_string($value)) { $date = call_user_func($this->parseDateCallback, $this->phpMask, $value); } else { $date = Nette\DateTime::from($value); } if (!$date instanceof DateTime) { throw new InvalidArgumentException("Invalid input for calendar picker: '{$value}'"); } $this->year = $date->format('Y'); $this->month = $date->format('n'); $this->day = $date->format('j'); if ($this->useTime) { $this->hour = $date->format('G'); $this->minute = (int) $date->format('i'); $this->second = (int) $date->format('s'); } } else { $this->year = $this->month = $this->day = NULL; if ($this->useTime) { $this->hour = $this->minute = $this->second = NULL; } } }
/** * Sets DatePicker value. * * @author Jan Tvrdík * @param DateTime|int|string * @return self */ public function setValue($value) { if ($value instanceof DateTime) { } elseif (is_int($value)) { // timestamp } elseif (empty($value)) { $rawValue = $value; $value = NULL; } elseif (is_string($value)) { $rawValue = $value; if (preg_match('#^(?P<hh>\\d{1,2})[:](?P<mm>\\d{1,2})([:](?P<ss>\\d{2})?)?$#', $value, $matches)) { $hh = $matches['hh']; $mm = $matches['mm']; $ss = isset($matches['ss']) ? $matches['ss'] : '00'; // if (checkdate($mm, $dd, $yyyy)) { $value = "{$hh}:{$mm}:{$ss}"; // } else { // $value = NULL; // } } } else { throw new \InvalidArgumentException(); } if ($value !== NULL) { // DateTime constructor throws Exception when invalid input given try { $value = Nette\DateTime::from($value); // clone DateTime when given } catch (\Exception $e) { $value = NULL; } } if (!isset($rawValue) && isset($value)) { $rawValue = $value->format(self::W3C_DATE_FORMAT); } $this->value = $value; $this->rawValue = $rawValue; return $this; }
/** * Parse column * @param mixed $value * @param mixed $rowData * @return mixed|string */ public function render($value, $rowData) { $value = parent::render($value, $rowData); $value = \Nette\DateTime::from($value); return $value->format($this->format); }
/** * * @param float $amount * @param string $iban * @param string $bic * @param string $benefName * @param string $benefCountry * @throws FioException */ public function addPaymentForeing($amount, $iban, $bic, $benefName, $benefCountry) { if ($this->content) { $this->createEmptyXml(); } if (strlen($bic) != 11) { throw new FioException('BIC must lenght 11. Is ISO 9362.'); } if (strlen($benefCountry) != 2 && $benefCountry != 'TCH') { throw new FioException('Country code consists of two letters.'); } $this->xml->startElement('T2Transaction'); $this->xmlContent($amount, $iban); $this->addXmlNode('bic', $bic, TRUE); $this->addXmlNode('date', DateTime::from($this->date)->format('Y-m-d')); $this->addXmlNode('comment', $this->comment); $this->addXmlNode('benefName', $benefName, TRUE); $this->addXmlNode('benefStreet', $this->benefStreet); $this->addXmlNode('benefCity', $this->benefCity); $this->addXmlNode('benefCountry', strtoupper($benefCountry), TRUE); $this->addXmlNode('remittanceInfo1', $this->remittanceInfo1); $this->addXmlNode('remittanceInfo2', $this->remittanceInfo2); $this->addXmlNode('remittanceInfo3', $this->remittanceInfo3); $this->addXmlNode('paymentReason', $this->paymentReason, FALSE); $this->addXmlNode('paymentType', $this->paymentTypeEuro, self::PAYMENT_STANDARD_EURO); $this->xml->endElement(); }
/** * Sends a cookie. * @param string name of the cookie * @param string value * @param string|int|DateTime expiration time, value 0 means "until the browser is closed" * @param string * @param string * @param bool * @param bool * @return self * @throws Nette\InvalidStateException if HTTP headers have been sent */ public function setCookie($name, $value, $time, $path = NULL, $domain = NULL, $secure = NULL, $httpOnly = NULL) { if (!headers_sent() && ob_get_level() && ob_get_length()) { trigger_error("Possible problem: you are sending a cookie while already having some data in output buffer. This may not work if the outputted data grows. Try starting the session earlier.", E_USER_NOTICE); } if (headers_sent($file, $line)) { throw new Nette\InvalidStateException("Cannot set cookie after HTTP headers have been sent" . ($file ? " (output started at {$file}:{$line})." : ".")); } setcookie($name, $value, $time ? Nette\DateTime::from($time)->format('U') : 0, $path === NULL ? $this->cookiePath : (string) $path, $domain === NULL ? $this->cookieDomain : (string) $domain, $secure === NULL ? $this->cookieSecure : (bool) $secure, $httpOnly === NULL ? $this->cookieHttpOnly : (bool) $httpOnly); $this->removeDuplicateCookies(); return $this; }
/** * Enables log out after inactivity. * @param string|int|DateTime Number of seconds or timestamp * @param int Log out when the browser is closed | Clear the identity from persistent storage? * @return self */ public function setExpiration($time, $flags = 0) { $section = $this->getSessionSection(TRUE); if ($time) { $time = Nette\DateTime::from($time)->format('U'); $section->expireTime = $time; $section->expireDelta = $time - time(); } else { unset($section->expireTime, $section->expireDelta); } $section->expireIdentity = (bool) ($flags & self::CLEAR_IDENTITY); $section->expireBrowser = (bool) ($flags & self::BROWSER_CLOSED); $section->browserCheck = TRUE; $section->setExpiration(0, 'browserCheck'); $section->setExpiration($time, 'foo'); // time check return $this; }
/** * Date/time formatting. * @param string|int|DateTime * @param string * @return string */ public static function date($time, $format = NULL) { if ($time == NULL) { // intentionally == return NULL; } if (!isset($format)) { $format = self::$dateFormat; } $time = Nette\DateTime::from($time); return Strings::contains($format, '%') ? strftime($format, $time->format('U')) : $time->format($format); // formats using date() }
/** * Writes item into the cache. * Dependencies are: * - Cache::PRIORITY => (int) priority * - Cache::EXPIRATION => (timestamp) expiration * - Cache::SLIDING => (bool) use sliding expiration? * - Cache::TAGS => (array) tags * - Cache::FILES => (array|string) file names * - Cache::ITEMS => (array|string) cache items * - Cache::CONSTS => (array|string) cache items * * @param mixed key * @param mixed value * @param array dependencies * @return mixed value itself * @throws Nette\InvalidArgumentException */ public function save($key, $data, array $dp = NULL) { $this->key = is_scalar($key) ? (string) $key : serialize($key); $key = $this->namespace . md5($this->key); // convert expire into relative amount of seconds if (isset($dp[Cache::EXPIRATION])) { $dp[Cache::EXPIRATION] = Nette\DateTime::from($dp[Cache::EXPIRATION])->format('U') - time(); } // convert FILES into CALLBACKS if (isset($dp[self::FILES])) { //clearstatcache(); foreach ((array) $dp[self::FILES] as $item) { $dp[self::CALLBACKS][] = array(array(__CLASS__, 'checkFile'), $item, @filemtime($item)); // @ - stat may fail } unset($dp[self::FILES]); } // add namespaces to items if (isset($dp[self::ITEMS])) { $dp[self::ITEMS] = (array) $dp[self::ITEMS]; foreach ($dp[self::ITEMS] as $k => $item) { $dp[self::ITEMS][$k] = $this->namespace . md5(is_scalar($item) ? $item : serialize($item)); } } // convert CONSTS into CALLBACKS if (isset($dp[self::CONSTS])) { foreach ((array) $dp[self::CONSTS] as $item) { $dp[self::CALLBACKS][] = array(array(__CLASS__, 'checkConst'), $item, constant($item)); } unset($dp[self::CONSTS]); } if ($data instanceof Nette\Callback || $data instanceof \Closure) { Nette\Utils\CriticalSection::enter(); $data = $data->__invoke(); Nette\Utils\CriticalSection::leave(); } if (is_object($data)) { $dp[self::CALLBACKS][] = array(array(__CLASS__, 'checkSerializationVersion'), get_class($data), Nette\Reflection\ClassType::from($data)->getAnnotation('serializationVersion')); } $this->data = $data; if ($data === NULL) { $this->storage->remove($key); } else { $this->storage->write($key, $data, (array) $dp); } return $data; }
private function completeDependencies($dp, $data) { if (is_object($data)) { $dp[self::CALLBACKS][] = array(array(__CLASS__, 'checkSerializationVersion'), get_class($data), Nette\Reflection\ClassType::from($data)->getAnnotation('serializationVersion')); } // convert expire into relative amount of seconds if (isset($dp[Cache::EXPIRATION])) { $dp[Cache::EXPIRATION] = Nette\DateTime::from($dp[Cache::EXPIRATION])->format('U') - time(); } // convert FILES into CALLBACKS if (isset($dp[self::FILES])) { //clearstatcache(); foreach (array_unique((array) $dp[self::FILES]) as $item) { $dp[self::CALLBACKS][] = array(array(__CLASS__, 'checkFile'), $item, @filemtime($item)); // @ - stat may fail } unset($dp[self::FILES]); } // add namespaces to items if (isset($dp[self::ITEMS])) { $dp[self::ITEMS] = array_unique(array_map(array($this, 'generateKey'), (array) $dp[self::ITEMS])); } // convert CONSTS into CALLBACKS if (isset($dp[self::CONSTS])) { foreach (array_unique((array) $dp[self::CONSTS]) as $item) { $dp[self::CALLBACKS][] = array(array(__CLASS__, 'checkConst'), $item, constant($item)); } unset($dp[self::CONSTS]); } if (!is_array($dp)) { $dp = array(); } return $dp; }
/** * Date/time formatting. * @param string|int|DateTime * @param string * @return string */ public static function date($time, $format = NULL) { if ($time == NULL) { // intentionally == return NULL; } if (!isset($format)) { $format = self::$dateFormat; } $time = Nette\DateTime::from($time); return strpos($format, '%') === FALSE ? $time->format($format) : strftime($format, $time->format('U')); // formats according to locales }
/** * Restricts the search by modified time. * @param string "[operator] [date]" example: >1978-01-23 * @param mixed * @return self */ public function date($operator, $date = NULL) { if (func_num_args() === 1) { // in $operator is predicate if (!preg_match('#^(?:([=<>!]=?|<>)\\s*)?(.+)\\z#i', $operator, $matches)) { throw new Nette\InvalidArgumentException('Invalid date predicate format.'); } list(, $operator, $date) = $matches; $operator = $operator ? $operator : '='; } $date = Nette\DateTime::from($date)->format('U'); return $this->filter(function ($file) use($operator, $date) { return Finder::compare($file->getMTime(), $operator, $date); }); }
/** * Sends a cookie. * @param string name of the cookie * @param string value * @param string|int|DateTime expiration time, value 0 means "until the browser is closed" * @param string * @param string * @param bool * @param bool * @return Response provides a fluent interface * @throws Nette\InvalidStateException if HTTP headers have been sent */ public function setCookie($name, $value, $time, $path = NULL, $domain = NULL, $secure = NULL, $httpOnly = NULL) { if (headers_sent($file, $line)) { throw new Nette\InvalidStateException("Cannot set cookie after HTTP headers have been sent" . ($file ? " (output started at {$file}:{$line})." : ".")); } setcookie($name, $value, $time ? Nette\DateTime::from($time)->format('U') : 0, $path === NULL ? $this->cookiePath : (string) $path, $domain === NULL ? $this->cookieDomain : (string) $domain, $secure === NULL ? $this->cookieSecure : (bool) $secure, $httpOnly === NULL ? $this->cookieHttpOnly : (bool) $httpOnly); $flatten = array(); foreach (headers_list() as $header) { if (preg_match('#^Set-Cookie: .+?=#', $header, $m)) { $flatten[$m[0]] = $header; if (PHP_VERSION_ID < 50300) { // multiple deleting due PHP bug #61605 header('Set-Cookie:'); } else { header_remove('Set-Cookie'); } } } foreach (array_values($flatten) as $key => $header) { header($header, $key === 0); } return $this; }
/** * Sends a cookie. * @param string name of the cookie * @param string value * @param string|int|DateTime expiration time, value 0 means "until the browser is closed" * @param string * @param string * @param bool * @param bool * @return Response provides a fluent interface * @throws Nette\InvalidStateException if HTTP headers have been sent */ public function setCookie($name, $value, $time, $path = NULL, $domain = NULL, $secure = NULL, $httpOnly = NULL) { if (headers_sent($file, $line)) { throw new Nette\InvalidStateException("Cannot set cookie after HTTP headers have been sent" . ($file ? " (output started at {$file}:{$line})." : ".")); } setcookie($name, $value, $time ? Nette\DateTime::from($time)->format('U') : 0, $path === NULL ? $this->cookiePath : (string) $path, $domain === NULL ? $this->cookieDomain : (string) $domain, $secure === NULL ? $this->cookieSecure : (bool) $secure, $httpOnly === NULL ? $this->cookieHttpOnly : (bool) $httpOnly); return $this; }
/** * Na datum posledního neúspěšně staženého dne * * @param mixed $date * @return string */ public function setLastDate($date) { $this->requestUrl = self::REST_URL . sprintf('set-last-date/%s/%s/', $this->token, DateTime::from($date)->format('Y-m-d')); $this->availableAnotherRequest(); return CurlBuilder::download($this->requestUrl); }
/** * Enables log out after inactivity. * @param string|int|DateTime number of seconds or timestamp * @param bool log out when the browser is closed? * @param bool clear the identity from persistent storage? * @return User provides a fluent interface */ public function setExpiration($time, $whenBrowserIsClosed = TRUE, $clearIdentity = FALSE) { $session = $this->getSessionSection(TRUE); if ($time) { $time = Nette\DateTime::from($time)->format('U'); $session->expireTime = $time; $session->expireDelta = $time - time(); } else { unset($session->expireTime, $session->expireDelta); } $session->expireIdentity = (bool) $clearIdentity; $session->expireBrowser = (bool) $whenBrowserIsClosed; $session->browserCheck = TRUE; $session->setExpiration(0, 'browserCheck'); return $this; }
/** * Sets DatePicker value. * * @author Jan Tvrdík * @param DateTime|int|string * @return self */ public function setValue($value) { if ($value instanceof DateTime) { } elseif (is_int($value)) { // timestamp } elseif (empty($value)) { $rawValue = $value; $value = NULL; } elseif (is_string($value)) { $rawValue = $value; if (preg_match('#^(?P<dd>\\d{1,2})[. -] *(?P<mm>\\d{1,2})([. -] *(?P<yyyy>\\d{4})?)?$#', $value, $matches)) { $dd = $matches['dd']; $mm = $matches['mm']; $yyyy = isset($matches['yyyy']) ? $matches['yyyy'] : date('Y'); if (checkdate($mm, $dd, $yyyy)) { $value = "{$yyyy}-{$mm}-{$dd}"; } else { $value = NULL; } } } else { throw new \InvalidArgumentException(); } if ($value !== NULL) { // DateTime constructor throws Exception when invalid input given try { $value = Nette\DateTime::from($value); // clone DateTime when given } catch (\Exception $e) { $value = NULL; } } if (!isset($rawValue) && isset($value)) { $rawValue = $value->format($this->format); } $this->value = $value; $this->rawValue = $rawValue; return $this; }