lib/Kolab

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


 lib/Kolab/FreeBusy/SourceIMAP.php |   21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

New commits:
commit 86b924672645155285dde6f13ebfb822c5711849
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Tue Aug 12 10:29:45 2014 -0400

    Convert all-day events into xxxxT000000Z/xxxxT235959Z UTC time ranges (#3298)

diff --git a/lib/Kolab/FreeBusy/SourceIMAP.php b/lib/Kolab/FreeBusy/SourceIMAP.php
index ee2092e..8fc0b7f 100644
--- a/lib/Kolab/FreeBusy/SourceIMAP.php
+++ b/lib/Kolab/FreeBusy/SourceIMAP.php
@@ -171,11 +171,18 @@ class SourceIMAP extends Source
 					// copied from libvcalendar::_to_ical()
 					$ve = VObject\Component::create('VEVENT');
 
-					// all-day events end the next day
-					if ($event['allday'] && !empty($event['end'])) {
-						$event['end'] = clone $event['end'];
-						$event['end']->add(new \DateInterval('P1D'));
-						$event['end']->_dateonly = true;
+					// translate all-day dates into absolute UTC times
+					// FIXME: use server timezone?
+					if ($event['allday']) {
+						$utc = new \DateTimeZone('UTC');
+						if (!empty($event['start'])) {
+							$event['start']->setTimeZone($utc);
+							$event['start']->setTime(0,0,0);
+						}
+						if (!empty($event['end'])) {
+							$event['end']->setTimeZone($utc);
+							$event['end']->setTime(23,59,59);
+						}
 					}
 
 					// avoid duplicate entries
@@ -186,9 +193,9 @@ class SourceIMAP extends Source
 					}
 
 					if (!empty($event['start']))
-						$ve->add(\libvcalendar::datetime_prop('DTSTART', $event['start'], false, (bool)$event['allday']));
+						$ve->add(\libvcalendar::datetime_prop('DTSTART', $event['start'], false, false));
 					if (!empty($event['end']))
-						$ve->add(\libvcalendar::datetime_prop('DTEND',   $event['end'], false, (bool)$event['allday']));
+						$ve->add(\libvcalendar::datetime_prop('DTEND',   $event['end'], false, false));
 
 					if (!empty($event['free_busy']))
 						$ve->add('TRANSP', $event['free_busy'] == 'free' ? 'TRANSPARENT' : 'OPAQUE');




More information about the commits mailing list