Fix recurrence enddate again

This commit is contained in:
Jörg Lehrke 2010-06-11 22:13:27 +00:00
parent 3e24e1c7d6
commit f54410da4f
2 changed files with 22 additions and 29 deletions

View File

@ -342,24 +342,6 @@ class calendar_ical extends calendar_boupdate
}
$event['recur_type'] = MCAL_RECUR_NONE;
}
elseif ($event['recur_enddate'])
{
$time = new egw_time($event['recur_enddate'],egw_time::$server_timezone);
// all calculations in the event's timezone
$time->setTimezone(self::$tz_cache[$event['tzid']]);
if (empty($event['whole_day']) && !empty($event['end']))
{
$end = new egw_time($event['end'],egw_time::$server_timezone);
$end->setTimezone(self::$tz_cache[$event['tzid']]);
$arr = egw_time::to($end,'array');
$time->setTime($arr['hour'],$arr['minute'],$arr['second']);
}
else
{
$time->setTime(23, 59, 59);
}
$event['recur_enddate'] = egw_time::to($time, 'server');
}
// check if tzid of event (not only recuring ones) is already added to export
if ($tzid && $tzid != 'UTC' && !in_array($tzid,$vtimezones_added))
@ -621,11 +603,23 @@ class calendar_ical extends calendar_boupdate
if ($event['recur_type'] == MCAL_RECUR_NONE) break; // no recuring event
$rriter = calendar_rrule::event2rrule($event, false, $tzid);
$rrule = $rriter->generate_rrule($version);
if ($event['recur_enddate'])
{
if ($tzid || $version != '1.0')
{
if (!isset(self::$tz_cache['UTC']))
{
self::$tz_cache['UTC'] = calendar_timezones::DateTimeZone('UTC');
}
$rrule['UNTIL']->setTimezone(self::$tz_cache['UTC']);
$rrule['UNTIL'] = $rrule['UNTIL']->format('Ymd\THis\Z');
}
}
if ($version == '1.0')
{
if ($event['recur_enddate'] && $tzid)
{
$rrule['UNTIL'] = self::getDateTime($event['recur_enddate'],$tzid);
$rrule['UNTIL'] = self::getDateTime($rrule['UNTIL'],$tzid);
}
$attributes['RRULE'] = $rrule['FREQ'].' '.$rrule['UNTIL'];
}

View File

@ -538,13 +538,6 @@ class calendar_rrule implements Iterator
$repeat_days = array();
$rrule = array();
if (!isset(self::$tz_cache['UTC']))
{
self::$tz_cache['UTC'] = calendar_timezones::DateTimeZone('UTC');
}
$utc = self::$tz_cache['UTC'];
if ($this->type == self::NONE) return false; // no recuring event
if ($version == '1.0')
@ -613,9 +606,15 @@ class calendar_rrule implements Iterator
if ($this->enddate)
{
$enddate = clone $this->enddate;
$enddate->setTimezone($utc);
$rrule['UNTIL'] = $enddate->format('Ymd\THis\Z');
$this->rewind();
$enddate = $this->current();
do
{
$this->next_no_exception();
$occurrence = $this->current();
}
while ($this->valid() && ($enddate = $occurrence));
$rrule['UNTIL'] = $enddate;
}
return $rrule;