From bde6195cbd78033ca621252ba8dce5f7e85eab6e Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Thu, 28 May 2009 12:04:55 +0200 Subject: [PATCH] Provide sane default values for start and end dates if none have been specified. --- kronolith/lib/Driver/Holidays.php | 9 +++++++++ kronolith/lib/Driver/Horde.php | 11 +++++++++++ kronolith/lib/Driver/Ical.php | 11 +++++++++++ 3 files changed, 31 insertions(+) diff --git a/kronolith/lib/Driver/Holidays.php b/kronolith/lib/Driver/Holidays.php index a8f6e0d3a..3ad4df66e 100644 --- a/kronolith/lib/Driver/Holidays.php +++ b/kronolith/lib/Driver/Holidays.php @@ -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(); } diff --git a/kronolith/lib/Driver/Horde.php b/kronolith/lib/Driver/Horde.php index 082b63471..c9e8c1b95 100644 --- a/kronolith/lib/Driver/Horde.php +++ b/kronolith/lib/Driver/Horde.php @@ -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; diff --git a/kronolith/lib/Driver/Ical.php b/kronolith/lib/Driver/Ical.php index 8fcf4b2ff..2479a08d3 100644 --- a/kronolith/lib/Driver/Ical.php +++ b/kronolith/lib/Driver/Ical.php @@ -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; -- 2.11.0