Fix recurrence UNTIL calculation

This commit is contained in:
Jörg Lehrke 2009-12-04 15:38:36 +00:00
parent b1ba17a702
commit 1e32ee4442

View File

@ -247,8 +247,14 @@ class calendar_ical extends calendar_boupdate
} }
elseif ($event['recur_enddate']) elseif ($event['recur_enddate'])
{ {
$recur_enddate = (int)$event['recur_enddate']; $delta = $event['end'] - mktime(0, 0, 0,
$recur_enddate += 24 * 60 * 60 - 1; date('m', $event['start']),
date('d', $event['start']),
date('Y', $event['start'])
);
if ($delta == 0) $delta = 24 * 60 * 60;
$event['recur_enddate'] += $delta;
} }
if ($this->log) error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".array2string($event)."\n",3,$this->logfile); if ($this->log) error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".array2string($event)."\n",3,$this->logfile);
@ -435,7 +441,7 @@ class calendar_ical extends calendar_boupdate
if ($event['recur_enddate']) if ($event['recur_enddate'])
{ {
$rrule['UNTIL'] = $vcal->_exportDateTime($recur_enddate); $rrule['UNTIL'] = $vcal->_exportDateTime($event['recur_enddate']);
} }
else else
{ {
@ -473,7 +479,7 @@ class calendar_ical extends calendar_boupdate
if ($event['recur_enddate']) if ($event['recur_enddate'])
{ {
// UNTIL should be a UTC timestamp // UNTIL should be a UTC timestamp
$rrule['UNTIL'] = $vcal->_exportDateTime($recur_enddate); $rrule['UNTIL'] = $vcal->_exportDateTime($event['recur_enddate']);
} }
$attributes['RRULE'] = ''; $attributes['RRULE'] = '';
$parameters['RRULE'] = $rrule; $parameters['RRULE'] = $rrule;
@ -1656,7 +1662,10 @@ class calendar_ical extends calendar_boupdate
if (!empty($vcardData['recur_count'])) if (!empty($vcardData['recur_count']))
{ {
$vcardData['recur_enddate'] = mktime(0,0,0, $vcardData['recur_enddate'] = mktime(
date('H', $vcardData['end']),
date('i', $vcardData['end']),
date('s', $vcardData['end']),
date('m', $vcardData['start']), date('m', $vcardData['start']),
date('d', $vcardData['start']) + ($vcardData['recur_interval']*($vcardData['recur_count']-1)*7), date('d', $vcardData['start']) + ($vcardData['recur_interval']*($vcardData['recur_count']-1)*7),
date('Y', $vcardData['start'])); date('Y', $vcardData['start']));
@ -1695,7 +1704,10 @@ class calendar_ical extends calendar_boupdate
if (!empty($vcardData['recur_count'])) if (!empty($vcardData['recur_count']))
{ {
$vcardData['recur_enddate'] = mktime(0,0,0, $vcardData['recur_enddate'] = mktime(
date('H', $vcardData['end']),
date('i', $vcardData['end']),
date('s', $vcardData['end']),
date('m', $vcardData['start']), date('m', $vcardData['start']),
date('d', $vcardData['start']) + ($vcardData['recur_interval']*($vcardData['recur_count']-1)), date('d', $vcardData['start']) + ($vcardData['recur_interval']*($vcardData['recur_count']-1)),
date('Y', $vcardData['start'])); date('Y', $vcardData['start']));
@ -1750,7 +1762,10 @@ class calendar_ical extends calendar_boupdate
if (!empty($vcardData['recur_count'])) if (!empty($vcardData['recur_count']))
{ {
$vcardData['recur_enddate'] = mktime(0,0,0, $vcardData['recur_enddate'] = mktime(
date('H', $vcardData['end']),
date('i', $vcardData['end']),
date('s', $vcardData['end']),
date('m', $vcardData['start']) + ($vcardData['recur_interval']*($vcardData['recur_count']-1)), date('m', $vcardData['start']) + ($vcardData['recur_interval']*($vcardData['recur_count']-1)),
date('d', $vcardData['start']), date('d', $vcardData['start']),
date('Y', $vcardData['start'])); date('Y', $vcardData['start']));
@ -1788,7 +1803,10 @@ class calendar_ical extends calendar_boupdate
if (!empty($vcardData['recur_count'])) if (!empty($vcardData['recur_count']))
{ {
$vcardData['recur_enddate'] = mktime(0,0,0, $vcardData['recur_enddate'] = mktime(
date('H', $vcardData['end']),
date('i', $vcardData['end']),
date('s', $vcardData['end']),
date('m', $vcardData['start']), date('m', $vcardData['start']),
date('d', $vcardData['start']), date('d', $vcardData['start']),
date('Y', $vcardData['start']) + ($vcardData['recur_interval']*($vcardData['recur_count']-1))); date('Y', $vcardData['start']) + ($vcardData['recur_interval']*($vcardData['recur_count']-1)));