* 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:23:08 +00:00
parent e49158d7c1
commit a3549df5e2

View File

@ -2287,8 +2287,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'])
{ {
@ -2348,6 +2351,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']))
@ -2364,16 +2379,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;