Provide sane default values for start and end dates if none have been specified.
authorJan Schneider <jan@horde.org>
Thu, 28 May 2009 10:04:55 +0000 (12:04 +0200)
committerJan Schneider <jan@horde.org>
Thu, 28 May 2009 12:47:12 +0000 (14:47 +0200)
kronolith/lib/Driver/Holidays.php
kronolith/lib/Driver/Horde.php
kronolith/lib/Driver/Ical.php

index a8f6e0d..3ad4df6 100644 (file)
@@ -46,6 +46,15 @@ class Kronolith_Driver_Holidays extends Kronolith_Driver
                               __FILE__, __LINE__, PEAR_LOG_ERR);
             return array();
         }
+
+        if (is_null($startDate) && !is_null($endDate)) {
+            $startDate = clone $endDate;
+            $startDate->year--;
+        }
+        if (is_null($endDate) && !is_null($startDate)) {
+            $endDate = clone $startDate;
+            $endDate->year++;
+        }
         if ($hasAlarm || is_null($startDate) || is_null($endDate)) {
             return array();
         }
index 082b634..c9e8c1b 100644 (file)
@@ -63,6 +63,17 @@ class Kronolith_Driver_Horde extends Kronolith_Driver
             return $eventsList;
         }
 
+        if (is_null($startDate)) {
+            $startDate = new Horde_Date(array('mday' => 1,
+                                              'month' => 1,
+                                              'year' => 0000));
+        }
+        if (is_null($endDate)) {
+            $endDate = new Horde_Date(array('mday' => 31,
+                                            'month' => 12,
+                                            'year' => 9999));
+        }
+
         $startDate = clone $startDate;
         $startDate->hour = $startDate->min = $startDate->sec = 0;
         $endDate = clone $endDate;
index 8fcf4b2..2479a08 100644 (file)
@@ -60,6 +60,17 @@ class Kronolith_Driver_Ical extends Kronolith_Driver
             return $iCal;
         }
 
+        if (is_null($startDate)) {
+            $startDate = new Horde_Date(array('mday' => 1,
+                                              'month' => 1,
+                                              'year' => 0000));
+        }
+        if (is_null($endDate)) {
+            $endDate = new Horde_Date(array('mday' => 31,
+                                            'month' => 12,
+                                            'year' => 9999));
+        }
+
         $startDate = clone $startDate;
         $startDate->hour = $startDate->min = $startDate->sec = 0;
         $endDate = clone $endDate;