From 173eb4e1100e2b8cb489274af3fe92a72b3dea04 Mon Sep 17 00:00:00 2001 From: nathan Date: Tue, 7 Jun 2022 14:33:22 -0600 Subject: [PATCH] Calendar: Fix all-day events in a different timezone could slide by a day Ex: 1977-04-29 created in CET (+1) on a server in UTC would change to the 28th after a few years (1980) Fixed by staying in server timezone for the recurrence calculations. --- calendar/inc/class.calendar_bo.inc.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/calendar/inc/class.calendar_bo.inc.php b/calendar/inc/class.calendar_bo.inc.php index b0bf5717a3..a76374c516 100644 --- a/calendar/inc/class.calendar_bo.inc.php +++ b/calendar/inc/class.calendar_bo.inc.php @@ -1160,16 +1160,22 @@ class calendar_bo // unset exceptions, as we need to add them as recurrence too, but marked as exception unset($event['recur_exception']); // loop over all recurrences and insert them, if they are after $start - $rrule = calendar_rrule::event2rrule($event, !$event['whole_day'], Api\DateTime::$user_timezone->getName()); // true = we operate in usertime, like the rest of calendar_bo + $rrule = calendar_rrule::event2rrule($event, !$event['whole_day'], // true = we operate in usertime, like the rest of calendar_bo + // For whole day events, just stay in server time + $event['whole_day'] ? Api\DateTime::$server_timezone->getName() : Api\DateTime::$user_timezone->getName() + ); foreach($rrule as $time) { - $time->setUser(); // $time is in timezone of event, convert it to usertime used here + // $time is in timezone of event, convert it to usertime used here if($event['whole_day']) { // All day events are processed in server timezone - $time->setServer(); $time->setTime(0,0,0); } + else + { + $time->setUser(); + } if (($ts = $this->date2ts($time)) < $start-$event_length) { //echo "

".$time." --> ignored as $ts < $start-$event_length

\n";