From 57090af3f81dacfb85c6b8e90307d1641abf1720 Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Tue, 12 Aug 2014 16:52:44 +0200 Subject: [PATCH] Detect all-day events in free/busy data and shift into user's timezone to cover the full day --- plugins/calendar/calendar.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php index 3160b6be..4063bd9e 100644 --- a/plugins/calendar/calendar.php +++ b/plugins/calendar/calendar.php @@ -1890,12 +1890,12 @@ class calendar extends rcube_plugin // convert dates into unix timestamps if (!empty($start) && !is_numeric($start)) { - $dts = new DateTime($start, $this->timezone); - $start = $dts->format('U'); + $dts = rcube_utils::anytodatetime($start, $this->timezone); + $start = $dts ? $dts->format('U') : null; } if (!empty($end) && !is_numeric($end)) { - $dte = new DateTime($end, $this->timezone); - $end = $dte->format('U'); + $dte = rcube_utils::anytodatetime($end, $this->timezone); + $end = $dte ? $dte->format('U') : null; } if (!$start) $start = time(); @@ -1922,6 +1922,14 @@ class calendar extends rcube_plugin $status = self::FREEBUSY_FREE; foreach ($fblist as $slot) { list($from, $to, $type) = $slot; + + // check for possible all-day times + if (gmdate('His', $from) == '000000' && gmdate('His', $to) == '235959') { + // shift into the user's timezone for sane matching + $from -= $this->gmt_offset; + $to -= $this->gmt_offset; + } + if ($from < $t_end && $to > $t) { $status = isset($type) ? $type : self::FREEBUSY_BUSY; if ($status == self::FREEBUSY_BUSY) // can't get any worse :-)