3 final class PhabricatorSearchDateField
4 extends PhabricatorSearchField
{
6 protected function newControl() {
7 return id(new AphrontFormTextControl())
8 ->setPlaceholder(pht('"2022-12-25" or "7 days ago"...'));
11 protected function getValueFromRequest(AphrontRequest
$request, $key) {
12 return $request->getStr($key);
15 public function getValueForQuery($value) {
16 return $this->parseDateTime($value);
19 protected function validateControlValue($value) {
20 if ($value === null ||
!strlen($value)) {
24 $epoch = $this->parseDateTime($value);
31 pht('Date value for "%s" can not be parsed.', $this->getLabel()));
34 protected function parseDateTime($value) {
35 if ($value === null ||
!strlen($value)) {
39 // If this appears to be an epoch timestamp, just return it unmodified.
40 // This assumes values like "2016" or "20160101" are "Ymd".
41 if (is_int($value) ||
ctype_digit($value)) {
42 if ((int)$value > 30000000) {
47 return PhabricatorTime
::parseLocalTime($value, $this->getViewer());
50 protected function newConduitParameterType() {
51 return new ConduitEpochParameterType();