Changeset View
Changeset View
Standalone View
Standalone View
src/applications/search/field/PhabricatorSearchDateField.php
Show All 11 Lines | protected function getValueFromRequest(AphrontRequest $request, $key) { | ||||||||
return $request->getStr($key); | return $request->getStr($key); | ||||||||
} | } | ||||||||
public function getValueForQuery($value) { | public function getValueForQuery($value) { | ||||||||
return $this->parseDateTime($value); | return $this->parseDateTime($value); | ||||||||
} | } | ||||||||
protected function validateControlValue($value) { | protected function validateControlValue($value) { | ||||||||
if (!strlen($value)) { | if (!phutil_nonempty_scalar($value)) { | ||||||||
valerio.bozzolan: WARNING: The check `phutil_nonempty_string()` is probably too much strict here, since this… | |||||||||
return; | return; | ||||||||
} | } | ||||||||
$epoch = $this->parseDateTime($value); | $epoch = $this->parseDateTime($value); | ||||||||
if ($epoch) { | if ($epoch) { | ||||||||
return; | return; | ||||||||
} | } | ||||||||
$this->addError( | $this->addError( | ||||||||
pht('Invalid'), | pht('Invalid'), | ||||||||
pht('Date value for "%s" can not be parsed.', $this->getLabel())); | pht('Date value for "%s" can not be parsed.', $this->getLabel())); | ||||||||
} | } | ||||||||
protected function parseDateTime($value) { | protected function parseDateTime($value) { | ||||||||
if (!strlen($value)) { | if (!phutil_nonempty_scalar($value)) { | ||||||||
Not Done Inline Actions
WARNING: Same as above. valerio.bozzolan: WARNING: Same as above. | |||||||||
return null; | return null; | ||||||||
} | } | ||||||||
// If this appears to be an epoch timestamp, just return it unmodified. | // If this appears to be an epoch timestamp, just return it unmodified. | ||||||||
// This assumes values like "2016" or "20160101" are "Ymd". | // This assumes values like "2016" or "20160101" are "Ymd". | ||||||||
if (is_int($value) || ctype_digit($value)) { | if (is_int($value) || ctype_digit($value)) { | ||||||||
if ((int)$value > 30000000) { | if ((int)$value > 30000000) { | ||||||||
return (int)$value; | return (int)$value; | ||||||||
Show All 11 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0
In short:
For reference: