* CalDAV: fix recurring event one day short, if number of recurence specified together with event-length, after rrule in iCal

This commit is contained in:
Ralf Becker 2012-10-23 14:22:33 +00:00
parent 4b0559ab4d
commit 6127be47d7

View File

@ -2305,8 +2305,11 @@ class calendar_ical extends calendar_boupdate
'recur_type' => MCAL_RECUR_NONE, 'recur_type' => MCAL_RECUR_NONE,
'recur_exception' => array(), 'recur_exception' => array(),
); );
// we parse DTSTART and DTEND first // we need to parse DTSTART, DTEND or DURATION (in that order!) first
foreach ($component->_attributes as $attributes) foreach (array_merge(
$component->getAllAttributes('DTSTART'),
$component->getAllAttributes('DTEND'),
$component->getAllAttributes('DURATION')) as $attributes)
{ {
switch ($attributes['name']) switch ($attributes['name'])
{ {
@ -2366,6 +2369,18 @@ class calendar_ical extends calendar_boupdate
$dtend_ts -= 1; $dtend_ts -= 1;
} }
$vcardData['end'] = $dtend_ts; $vcardData['end'] = $dtend_ts;
break;
case 'DURATION': // clients can use DTSTART+DURATION, instead of DTSTART+DTEND
if (!isset($vcardData['end']))
{
$vcardData['end'] = $vcardData['start'] + $attributes['value'];
}
else
{
error_log(__METHOD__."() find DTEND AND DURATION --> ignoring DURATION");
}
break;
} }
} }
if (!isset($vcardData['start'])) if (!isset($vcardData['start']))
@ -2382,16 +2397,6 @@ class calendar_ical extends calendar_boupdate
{ {
switch ($attributes['name']) switch ($attributes['name'])
{ {
case 'DURATION': // clients can use DTSTART+DURATION, instead of DTSTART+DTEND
if (!isset($vcardData['end']))
{
$vcardData['end'] = $vcardData['start'] + $attributes['value'];
}
else
{
error_log(__METHOD__."() find DTEND AND DURATION --> ignoring DURATION");
}
break;
case 'X-MICROSOFT-CDO-ALLDAYEVENT': case 'X-MICROSOFT-CDO-ALLDAYEVENT':
$event['whole_day'] = (isset($attributes['value'])?strtoupper($attributes['value'])=='TRUE':true); $event['whole_day'] = (isset($attributes['value'])?strtoupper($attributes['value'])=='TRUE':true);
break; break;