Page MenuHomePhabricator

Patch: Calculate missing end date from duration
Closed, ResolvedPublic


I noticed that the davcal table view shows the current time as the end date when an event does not have an DTEND property.
In my case that happened when creating an recurring event in Nextcloud. It seems to be caused by the DateTime constructor in syntax/table.php:261 which gets called with null if $event['end'] is empty.

This patch calculates the end date using the DURATION property.

--- helper.php	2019-04-30 08:34:58.000000000 +0200
+++ helper_new.php	2020-02-10 19:06:52.203240422 +0100
@@ -1109,6 +1109,14 @@
           $entry['end'] = $dtEnd->format("Y-m-d");
           $entry['end'] = $dtEnd->format(\DateTime::ATOM);
+      } else {
+        if($event->DURATION !== null){
+          $interval = $event->DURATION->getDateInterval();
+          $datetime_start = new DateTime($start->getValue());
+          $dtEnd = $datetime_start->add($interval);
+          $dtEnd->setTimezone($timezone);
+          $entry['end'] = $dtEnd->format(\DateTime::ATOM);
+        }
       $description = $event->DESCRIPTION;
       if($description !== null)

Event Timeline

Thanks for the patch, I'll review and apply it as soon as possible (there is another patch pending that arrived via E-Mail that needs some work as well).

Finally, this should be fixed in rDAVCALe4bc2b1c0d4a53495d69bc0e916c5e70b3941ea2. Feel free to reopen if it doesn't work as intended.