Creates a Value from the given $dateTime.
public static fromDateTime ( DateTime $dateTime ) : |
||
$dateTime | DateTime | |
return |
/** * {@inheritDoc} * * @return TimeValue */ public function convertFieldValueFromForm($data) { if ($data instanceof DateTime) { return TimeValue::fromDateTime($data); } if (is_int($data)) { return new TimeValue($data); } return new TimeValue(null); }
/** * Inspects given $inputValue and potentially converts it into a dedicated value object. * * @param string|int|\DateTime|\eZ\Publish\Core\FieldType\Time\Value $inputValue * * @return \eZ\Publish\Core\FieldType\Time\Value The potentially converted and structurally plausible value. */ protected function createValueFromInput($inputValue) { if (is_string($inputValue)) { $inputValue = Value::fromString($inputValue); } if (is_int($inputValue)) { $inputValue = Value::fromTimestamp($inputValue); } if ($inputValue instanceof DateTime) { $inputValue = Value::fromDateTime($inputValue); } return $inputValue; }