plugins/calendar

Thomas Brüderli bruederli at kolabsys.com
Tue Aug 12 16:52:59 CEST 2014


 plugins/calendar/calendar.php |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

New commits:
commit 57090af3f81dacfb85c6b8e90307d1641abf1720
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Tue Aug 12 16:52:44 2014 +0200

    Detect all-day events in free/busy data and shift into user's timezone to cover the full day

diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php
index 3160b6b..4063bd9 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 :-)




More information about the commits mailing list