diff --git a/api/src/Etemplate/Widget/Customfields.php b/api/src/Etemplate/Widget/Customfields.php index aa795cfd0a..697e3c0d9e 100644 --- a/api/src/Etemplate/Widget/Customfields.php +++ b/api/src/Etemplate/Widget/Customfields.php @@ -24,11 +24,11 @@ class Customfields extends Transformer { /** - * Allowd types of customfields + * Allowed types of customfields * - * The additionally allowed app-names from the link-class, will be add by the edit-method only, - * as the link-class has to be called, which can NOT be instanciated by the constructor, as - * we get a loop in the instanciation. + * The additionally allowed app-names from the link-class, will be added by the edit-method only, + * as the link-class has to be called, which can NOT be instantiated by the constructor, as + * we get a loop in the instantiation. * * @var array */ diff --git a/api/src/Etemplate/Widget/Date.php b/api/src/Etemplate/Widget/Date.php index 73dc0671c5..e4b2568cb5 100644 --- a/api/src/Etemplate/Widget/Date.php +++ b/api/src/Etemplate/Widget/Date.php @@ -120,15 +120,17 @@ class Date extends Transformer { $date = Api\DateTime::server2user($value); } - elseif (!empty($this->attrs['data_format']) && $this->attrs['data_format'] !== 'object') + // if data_format given, try that first, before leaving it to Api\DateTime to figure it out + elseif (!empty($this->attrs['data_format']) && $this->attrs['data_format'] !== 'object' && + ($date = Api\DateTime::createFromFormat($this->attrs['data_format'], $value, Api\DateTime::$user_timezone))) { - $date = Api\DateTime::createFromFormat($this->attrs['data_format'], $value, Api\DateTime::$user_timezone); + // set AND checked above } else { $date = new Api\DateTime($value); } - if($this->type == 'date-timeonly' && $date) + if($this->type === 'date-timeonly' && $date) { $date->setDate(1970, 1, 1); }