meeting all day fix date time zone

This commit is contained in:
Yuri Kuznetsov
2020-03-19 19:40:15 +02:00
parent 32f07d81d4
commit 6dfd2d49bb

View File

@@ -251,15 +251,17 @@ class Event extends \Espo\Core\ORM\Repositories\RDB
protected function convertDateTimeToDefaultTimezone($string)
{
$dateTime = \DateTime::createFromFormat($this->getDateTime()->getInternalDateTimeFormat(), $string);
$timeZone = $this->getConfig()->get('timeZone');
if (empty($timeZone)) {
$timeZone = 'UTC';
}
$tz = $timezone = new \DateTimeZone($timeZone);
$timeZone = $this->getConfig()->get('timeZone') ?? 'UTC';
if ($dateTime) {
return $dateTime->setTimezone($tz)->format($this->getDateTime()->getInternalDateTimeFormat());
$tz = new \DateTimeZone($timeZone);
try {
$dt = \DateTime::createFromFormat($this->getDateTime()->getInternalDateTimeFormat(), $string, $tz);
} catch (\Exception $e) {}
if ($dt) {
$utcTz = new \DateTimeZone('UTC');
return $dt->setTimezone($utcTz)->format($this->getDateTime()->getInternalDateTimeFormat());
}
return null;
}