diff options
author | Richard Steinmetz <richard@steinmetz.cloud> | 2024-11-04 11:17:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-04 11:17:08 +0100 |
commit | d3cecf5b0a72107a2985087d9c94d21e8b6a6d80 (patch) | |
tree | 658db5954c04baac78ec95192c25dcb7d7dc3951 | |
parent | 901496276bccecc90c6b8cd247cc963073f23f52 (diff) | |
parent | cbcc8fc1a904dfb5057ca856472e04a88df5af75 (diff) | |
download | nextcloud-server-d3cecf5b0a72107a2985087d9c94d21e8b6a6d80.tar.gz nextcloud-server-d3cecf5b0a72107a2985087d9c94d21e8b6a6d80.zip |
Merge pull request #48723 from nextcloud/fix/caldav/event-reader-duration
fix(caldav): duration handling in the event reader class
-rw-r--r-- | apps/dav/lib/CalDAV/EventReader.php | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/apps/dav/lib/CalDAV/EventReader.php b/apps/dav/lib/CalDAV/EventReader.php index 6e845c596ae..7ff05501ea8 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; } @@ -375,7 +378,7 @@ class EventReader { * @return int|null */ public function recurringConcludesAfter(): ?int { - + // construct count place holder $count = 0; // retrieve and add RRULE iterations count |