Skip to content

Commit

Permalink
fixup! fix(CalDAV reminders): Fix timezone drift for all-day events
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Wurst <[email protected]>
  • Loading branch information
ChristophWurst committed Feb 8, 2023
1 parent 4bf3043 commit bbe17e6
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions apps/dav/lib/CalDAV/Reminder/ReminderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ public function onCalendarObjectCreate(array $objectData):void {

try {
$triggerTime = $valarm->getEffectiveTriggerTime();
/**
* @psalm-suppress DocblockTypeContradiction
* https://github.com/vimeo/psalm/issues/9244
*/
if ($triggerTime->getTimezone() === false || $triggerTime->getTimezone()->getName() === 'UTC') {
$triggerTime = new DateTimeImmutable(
$triggerTime->format('Y-m-d H:i:s'),
Expand Down Expand Up @@ -396,6 +400,10 @@ private function getRemindersForVAlarm(VAlarm $valarm,
$isRelative = $this->isAlarmRelative($valarm);
/** @var DateTimeImmutable $notificationDate */
$notificationDate = $valarm->getEffectiveTriggerTime();
/**
* @psalm-suppress DocblockTypeContradiction
* https://github.com/vimeo/psalm/issues/9244
*/
if ($notificationDate->getTimezone() === false || $notificationDate->getTimezone()->getName() === 'UTC') {
$notificationDate = new DateTimeImmutable(
$notificationDate->format('Y-m-d H:i:s'),
Expand Down Expand Up @@ -855,10 +863,11 @@ private function getCalendarTimeZone(int $calendarid): DateTimeZone {
// Defaulting to UTC
return new DateTimeZone('UTC');
}
// This property contains a VCALENDAR with a single
// VTIMEZONE.
// This property contains a VCALENDAR with a single VTIMEZONE
/** @var string $timezoneProp */
$timezoneProp = $calendarInfo[$tzProp];
/** @var VObject\Component\VCalendar $vtimezoneObj */
$vtimezoneObj = VObject\Reader::read($calendarInfo[$tzProp]);
$vtimezoneObj = VObject\Reader::read($timezoneProp);
/** @var VObject\Component\VTimeZone $vtimezone */
$vtimezone = $vtimezoneObj->VTIMEZONE;
return $vtimezone->getTimeZone();
Expand Down

0 comments on commit bbe17e6

Please sign in to comment.