diff --git a/lib/ics-parser/Event.php b/lib/ics-parser/Event.php index f3aa776..cd2f5c8 100644 --- a/lib/ics-parser/Event.php +++ b/lib/ics-parser/Event.php @@ -154,21 +154,20 @@ class Event { foreach ($data as $key => $value) { if ($key == 'DTSTART_array' || $key == 'DTEND_array') { + $timeZone = 'Europe/Berlin'; + if (isset($value[0]['TZID'])) { + $timeZone = $value[0]['TZID']; + } $dateString = $value[1]; - $dateTime = \DateTime::createFromFormat('Ymd\THis', $dateString); + + $dateTime = \DateTime::createFromFormat('Ymd\THis', $dateString, new \DateTimeZone($timeZone)); if (false === $dateTime) { $this->wholeDay = true; - $dateTime = \DateTime::createFromFormat('Ymd', $dateString); + $dateTime = \DateTime::createFromFormat('Ymd', $dateString, new \DateTimeZone($timeZone)); } - $timeZone = 'Europe/Berlin'; - if (isset($value[0]['TZID'])) { - $timeZone = $value[0]['TZID']; - } - - $dateTime->setTimezone(new \DateTimeZone($timeZone)); - + $dateTime->setTimezone(new \DateTimeZone('UTC')); if ($key == 'DTSTART_array') { $this->start = $dateTime->format('d.m.Y H:i:s'); $this->startInt = $dateTime->getTimestamp(); @@ -176,9 +175,7 @@ class Event $this->end = $dateTime->format('d.m.Y H:i:s'); $this->endInt = $dateTime->getTimestamp(); } - } else { - $variable = self::snakeCase($key); if (property_exists($this, $variable)) { $this->{$variable} = $this->prepareData($value); diff --git a/lib/ics-parser/ICal.php b/lib/ics-parser/ICal.php index f88e4f8..b7fbc37 100644 --- a/lib/ics-parser/ICal.php +++ b/lib/ics-parser/ICal.php @@ -2223,7 +2223,6 @@ class ICal if ($ignoreUtc && strtoupper($timeZone) === self::TIME_ZONE_UTC) { return null; } - return $timeZone; }