allow to pass JSON serialized date-array with date&timezone to constructor

This commit is contained in:
Ralf Becker 2021-05-14 20:24:01 +02:00
parent 30dea4034a
commit 1e2c7de6f7

View File

@ -143,6 +143,12 @@ class DateTime extends \DateTime
break; break;
case 'array': case 'array':
// JSON serialized DateTime object
if (isset($time['timezone_type']) && !empty($time['date']) && !empty($time['timezone']))
{
parent::__construct($time['date'], new DateTimeZone($time['timezone']));
break;
}
parent::__construct('now',$tz); parent::__construct('now',$tz);
if (isset($time['Y'])) // array format used in eTemplate if (isset($time['Y'])) // array format used in eTemplate
{ {