Fix setting start/end dates when requesting event listings.
authorJan Schneider <jan@horde.org>
Fri, 24 Sep 2010 16:36:05 +0000 (18:36 +0200)
committerJan Schneider <jan@horde.org>
Fri, 24 Sep 2010 16:37:02 +0000 (18:37 +0200)
kronolith/lib/Driver/Ical.php

index 8e38ebe..eab03be 100644 (file)
@@ -187,6 +187,16 @@ class Kronolith_Driver_Ical extends Kronolith_Driver
                                          $hasAlarm = false, $json = false,
                                          $coverDates = true)
     {
+        if (!is_null($startDate)) {
+            $startDate = clone $startDate;
+            $startDate->hour = $startDate->min = $startDate->sec = 0;
+        }
+        if (!is_null($endDate)) {
+            $endDate = clone $endDate;
+            $endDate->hour = 23;
+            $endDate->min = $endDate->sec = 59;
+        }
+
         /* Build report query. */
         $xml = new XMLWriter();
         $xml->openMemory();
@@ -210,9 +220,16 @@ class Kronolith_Driver_Ical extends Kronolith_Driver
         $xml->writeAttribute('name', 'VCALENDAR');
         $xml->startElement('C:comp-filter');
         $xml->writeAttribute('name', 'VEVENT');
-        $xml->startElement('C:time-range');
-        $xml->writeAttribute('start', $startDate->toiCalendar());
-        $xml->writeAttribute('end', $endDate->toiCalendar());
+        if (!is_null($startDate) ||
+            !is_null($endDate)) {
+            $xml->startElement('C:time-range');
+            if (!is_null($startDate)) {
+                $xml->writeAttribute('start', $startDate->toiCalendar());
+            }
+            if (!is_null($endDate)) {
+                $xml->writeAttribute('end', $endDate->toiCalendar());
+            }
+        }
         $xml->endDocument();
 
         $url = $this->_getUrl();