diff options
author | Richard Steinmetz <richard@steinmetz.cloud> | 2024-10-16 09:53:59 +0200 |
---|---|---|
committer | Richard Steinmetz <richard@steinmetz.cloud> | 2024-11-12 18:45:17 +0100 |
commit | 87ff49e1b80b248bc85c1c53f2553b96c07e0697 (patch) | |
tree | 34c3559000164d93edeb97a7df56926287a5feae /apps/dav | |
parent | bcb8fa8eac907f2d8e2b2b8b522134b49725b9c8 (diff) | |
download | nextcloud-server-87ff49e1b80b248bc85c1c53f2553b96c07e0697.tar.gz nextcloud-server-87ff49e1b80b248bc85c1c53f2553b96c07e0697.zip |
fix(caldav): duration handling in the event reader class
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
Diffstat (limited to 'apps/dav')
-rw-r--r-- | apps/dav/lib/CalDAV/EventReader.php | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/apps/dav/lib/CalDAV/EventReader.php b/apps/dav/lib/CalDAV/EventReader.php index 99e5677d432..6906572cc37 100644 --- a/apps/dav/lib/CalDAV/EventReader.php +++ b/apps/dav/lib/CalDAV/EventReader.php @@ -10,6 +10,7 @@ declare(strict_types=1); namespace OCA\DAV\CalDAV; use DateTime; +use DateTimeImmutable; use DateTimeInterface; use DateTimeZone; use InvalidArgumentException; @@ -109,7 +110,7 @@ class EventReader { unset($events[$key]); } } - + // No base event was found. CalDAV does allow cases where only // overridden instances are stored. // @@ -173,15 +174,17 @@ class EventReader { // evaluate if duration exists // extract duration and calculate end date elseif (isset($this->baseEvent->DURATION)) { - $this->baseEventDuration = $this->baseEvent->DURATION->getDateInterval(); - $this->baseEventEndDate = ((clone $this->baseEventStartDate)->add($this->baseEventDuration)); + $this->baseEventEndDate = DateTimeImmutable::createFromInterface($this->baseEventStartDate) + ->add($this->baseEvent->DURATION->getDateInterval()); + $this->baseEventDuration = $this->baseEventEndDate->getTimestamp() - $this->baseEventStartDate->getTimestamp(); } // evaluate if start date is floating // set duration to 24 hours and calculate the end date // according to the rfc any event without a end date or duration is a complete day elseif ($this->baseEventStartDateFloating == true) { $this->baseEventDuration = 86400; - $this->baseEventEndDate = ((clone $this->baseEventStartDate)->add($this->baseEventDuration)); + $this->baseEventEndDate = DateTimeImmutable::createFromInterface($this->baseEventStartDate) + ->setTimestamp($this->baseEventStartDate->getTimestamp() + $this->baseEventDuration); } // otherwise, set duration to zero this should never happen else { @@ -220,7 +223,7 @@ class EventReader { foreach ($events as $vevent) { $this->recurrenceModified[$vevent->{'RECURRENCE-ID'}->getDateTime($this->baseEventStartTimeZone)->getTimeStamp()] = $vevent; } - + $this->recurrenceCurrentDate = clone $this->baseEventStartDate; } |