From 4a6dbe37fd87f8774c93e75196cc9b4242356d31 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sun, 5 Oct 2008 07:56:50 +0000 Subject: [PATCH] "exporting whole day events with dates instead of times for DT{START|END}, as other clients fail to recognice them as such otherwise" --- calendar/inc/class.calendar_ical.inc.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/calendar/inc/class.calendar_ical.inc.php b/calendar/inc/class.calendar_ical.inc.php index bf0adbaca1..1c5da45d11 100644 --- a/calendar/inc/class.calendar_ical.inc.php +++ b/calendar/inc/class.calendar_ical.inc.php @@ -240,9 +240,22 @@ class calendar_ical extends calendar_boupdate break; case 'DTEND': - if(date('H:i:s',$event['end']) == '23:59:59') $event['end']++; - if(date('H:i:s',$event['end']) == '23:59:00') $event['end']+=60; // needed by old eGW whole-day events - $attributes[$icalFieldName] = $event['end']; + // write start + end of whole day events as dates + if (date('H:i:s',$event['start']) == '00:00:00' && in_array(date('H:i:s',$event['end']),array('23:59:59','23:59:00'))) + { + $event['end'] += 12*3600; // we need the date of the next day, as DTEND is non-inclusive (= exclusive) in rfc2445 + foreach(array('start' => 'DTSTART','end' => 'DTEND') as $f => $t) + { + $arr = calendar_bo::date2array($event[$f]); + $vevent->setAttribute($t, array('year' => $arr['year'],'month' => $arr['month'],'mday' => $arr['day']), + array('VALUE' => 'DATE')); + } + unset($attributes['DTSTART']); + } + else + { + $attributes['DTEND'] = $event['end']; + } break; case 'RRULE': @@ -431,10 +444,9 @@ class calendar_ical extends calendar_boupdate } $attributes['UID'] = $force_own_uid ? $eventGUID : $event['uid']; - foreach($attributes as $key => $value) { - foreach(is_array($value) ? $value : array($value) as $valueID => $valueData) + foreach(is_array($value)&&$parameters[$key]['VALUE']!='DATE' ? $value : array($value) as $valueID => $valueData) { $valueData = $GLOBALS['egw']->translation->convert($valueData,$GLOBALS['egw']->translation->charset(),'UTF-8'); $paramData = (array) $GLOBALS['egw']->translation->convert(is_array($value) ? $parameters[$key][$valueID] : $parameters[$key],