Bugfix timezone on events

This commit is contained in:
Thomas Günther 2024-03-02 18:13:44 +01:00
parent 9835f32dfa
commit dd6af287f3
2 changed files with 8 additions and 12 deletions

View File

@ -154,21 +154,20 @@ class Event
{ {
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
if ($key == 'DTSTART_array' || $key == 'DTEND_array') { if ($key == 'DTSTART_array' || $key == 'DTEND_array') {
$timeZone = 'Europe/Berlin';
if (isset($value[0]['TZID'])) {
$timeZone = $value[0]['TZID'];
}
$dateString = $value[1]; $dateString = $value[1];
$dateTime = \DateTime::createFromFormat('Ymd\THis', $dateString);
$dateTime = \DateTime::createFromFormat('Ymd\THis', $dateString, new \DateTimeZone($timeZone));
if (false === $dateTime) { if (false === $dateTime) {
$this->wholeDay = true; $this->wholeDay = true;
$dateTime = \DateTime::createFromFormat('Ymd', $dateString); $dateTime = \DateTime::createFromFormat('Ymd', $dateString, new \DateTimeZone($timeZone));
} }
$timeZone = 'Europe/Berlin'; $dateTime->setTimezone(new \DateTimeZone('UTC'));
if (isset($value[0]['TZID'])) {
$timeZone = $value[0]['TZID'];
}
$dateTime->setTimezone(new \DateTimeZone($timeZone));
if ($key == 'DTSTART_array') { if ($key == 'DTSTART_array') {
$this->start = $dateTime->format('d.m.Y H:i:s'); $this->start = $dateTime->format('d.m.Y H:i:s');
$this->startInt = $dateTime->getTimestamp(); $this->startInt = $dateTime->getTimestamp();
@ -176,9 +175,7 @@ class Event
$this->end = $dateTime->format('d.m.Y H:i:s'); $this->end = $dateTime->format('d.m.Y H:i:s');
$this->endInt = $dateTime->getTimestamp(); $this->endInt = $dateTime->getTimestamp();
} }
} else { } else {
$variable = self::snakeCase($key); $variable = self::snakeCase($key);
if (property_exists($this, $variable)) { if (property_exists($this, $variable)) {
$this->{$variable} = $this->prepareData($value); $this->{$variable} = $this->prepareData($value);

View File

@ -2223,7 +2223,6 @@ class ICal
if ($ignoreUtc && strtoupper($timeZone) === self::TIME_ZONE_UTC) { if ($ignoreUtc && strtoupper($timeZone) === self::TIME_ZONE_UTC) {
return null; return null;
} }
return $timeZone; return $timeZone;
} }