diff --git a/components/ILIAS/Calendar/classes/Export/class.ilCalendarExport.php b/components/ILIAS/Calendar/classes/Export/class.ilCalendarExport.php index cb3793697c02..f1da2893c122 100755 --- a/components/ILIAS/Calendar/classes/Export/class.ilCalendarExport.php +++ b/components/ILIAS/Calendar/classes/Export/class.ilCalendarExport.php @@ -306,7 +306,7 @@ protected function createRecurrences(ilCalendarEntry $app): ilICalWriter $str_writer = new ilICalWriter(); foreach (ilCalendarRecurrences::_getRecurrences($app->getEntryId()) as $rec) { foreach (ilCalendarRecurrenceExclusions::getExclusionDates($app->getEntryId()) as $excl) { - $str_writer->addLine($excl->toICal()); + $str_writer->addLine($excl->toICal($this->il_user->getTimeZone())); } $recurrence_ical = $rec->toICal($this->il_user->getId()); if (strlen($recurrence_ical)) { diff --git a/components/ILIAS/Calendar/classes/class.ilCalendarRecurrence.php b/components/ILIAS/Calendar/classes/class.ilCalendarRecurrence.php index c847c08648ca..f41f214075c5 100755 --- a/components/ILIAS/Calendar/classes/class.ilCalendarRecurrence.php +++ b/components/ILIAS/Calendar/classes/class.ilCalendarRecurrence.php @@ -106,8 +106,13 @@ public function toICal(int $a_user_id): string if ($entry->isFullday()) { $ical .= (';UNTIL=' . $this->getFrequenceUntilDate()->get(IL_CAL_FKT_DATE, 'Ymd')); } else { - $his = $entry->getStart()->get(IL_CAL_FKT_DATE, 'His'); - $ical .= (';UNTIL=' . $this->getFrequenceUntilDate()->get(IL_CAL_FKT_DATE, 'Ymd') . 'T' . $his); + $user = new ilObjUser($a_user_id); + $tz = $user->getTimeZone(); + $local_time = $entry->getStart()->get(IL_CAL_FKT_DATE, 'H:i:s', $tz); + $until_date = $this->getFrequenceUntilDate()->get(IL_CAL_FKT_DATE, 'Y-m-d'); + $until_dt = new ilDateTime($until_date . ' ' . $local_time, IL_CAL_DATETIME, $tz); + $ical .= ';UNTIL=' . $until_dt->get(IL_CAL_FKT_DATE, 'Ymd', ilTimeZone::UTC) . + 'T' . $until_dt->get(IL_CAL_FKT_DATE, 'His', ilTimeZone::UTC) . 'Z'; } } if ($this->getBYMONTH()) { diff --git a/components/ILIAS/Calendar/classes/class.ilCalendarRecurrenceExclusion.php b/components/ILIAS/Calendar/classes/class.ilCalendarRecurrenceExclusion.php index 54361e1037c3..1ac742b64eef 100755 --- a/components/ILIAS/Calendar/classes/class.ilCalendarRecurrenceExclusion.php +++ b/components/ILIAS/Calendar/classes/class.ilCalendarRecurrenceExclusion.php @@ -67,7 +67,7 @@ public function setDate(?ilDate $dt = null): void $this->exclusion = $dt; } - public function toICal(): string + public function toICal(string $a_tz = ''): string { $entry = new ilCalendarEntry($this->getEntryId()); $start = $entry->getStart(); @@ -75,9 +75,13 @@ public function toICal(): string if ($entry->isFullday()) { return 'EXDATE;VALUE=DATE:' . $this->getDate()->get(IL_CAL_FKT_DATE, 'Ymd'); } else { + $tz = $a_tz ?: ilTimeZone::UTC; + $local_time = $start->get(IL_CAL_FKT_DATE, 'H:i:s', $tz); + $excl_date = $this->getDate()->get(IL_CAL_FKT_DATE, 'Y-m-d'); + $excl_dt = new ilDateTime($excl_date . ' ' . $local_time, IL_CAL_DATETIME, $tz); return 'EXDATE:' . - $this->getDate()->get(IL_CAL_FKT_DATE, 'Ymd', ilTimeZone::UTC) . - 'T' . $start->get(IL_CAL_FKT_DATE, 'His', ilTimeZone::UTC) . 'Z'; + $excl_dt->get(IL_CAL_FKT_DATE, 'Ymd', ilTimeZone::UTC) . + 'T' . $excl_dt->get(IL_CAL_FKT_DATE, 'His', ilTimeZone::UTC) . 'Z'; } }