Implements TypedDataInterface::setValue().
Overrides TypedData::setValue
public function setValue($value) {
// Don't try to create a date from an empty value.
// It would default to the current time.
if (!isset($value)) {
$this->value = $value;
}
else {
$this->value = $value instanceof DrupalDateTime ? $value : new DrupalDateTime($value);
if ($this->value
->hasErrors()) {
throw new InvalidArgumentException("Invalid date format given.");
}
}
}