1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Allow standard date fields to read default dates as strings

Summary: Ref T2217. Fixes T3866. We need to do a little more massaging before we can set strings as the value on datetime controls.

Test Plan: Set default to "1:23 AM", "2001/02/03".

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2217, T3866

Differential Revision: https://secure.phabricator.com/D7116
This commit is contained in:
epriestley 2013-09-25 11:17:05 -07:00
parent 6d45a2e09b
commit bef6d82cce

View file

@ -65,7 +65,18 @@ final class PhabricatorStandardCustomFieldDate
->setCaption($this->getCaption())
->setAllowNull(!$this->getRequired());
$control->setValue($this->getFieldValue());
// If the value is already numeric, treat it as an epoch timestamp and set
// it directly. Otherwise, it's likely a field default, which we let users
// specify as a string. Parse the string into an epoch.
$value = $this->getFieldValue();
if (!ctype_digit($value)) {
$value = PhabricatorTime::parseLocalTime($value, $this->getViewer());
}
// If we don't have anything valid, make sure we pass `null`, since the
// control special-cases that.
$control->setValue(nonempty($value, null));
return $control;
}