summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2014-08-12 14:29:45 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2014-08-12 14:29:45 (GMT)
commit86b924672645155285dde6f13ebfb822c5711849 (patch)
tree36be4dc5aa5770c10b96fb317f3de61fa19fc0e1
parent5831b1ddf686d4536ef2059f1a90cd6ff4ff99d6 (diff)
downloadkolab-freebusy-86b924672645155285dde6f13ebfb822c5711849.tar.gz
Convert all-day events into xxxxT000000Z/xxxxT235959Z UTC time ranges (#3298)
-rw-r--r--lib/Kolab/FreeBusy/SourceIMAP.php21
1 files changed, 14 insertions, 7 deletions
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');