public function fromRRule10($rrule)
{
$this->reset();
if (!$rrule) {
return;
}
if (!preg_match('/([A-Z]+)(\\d+)?(.*)/', $rrule, $matches)) {
// No recurrence data - event does not recur.
$this->setRecurType(self::RECUR_NONE);
}
// Always default the recurInterval to 1.
$this->setRecurInterval(!empty($matches[2]) ? $matches[2] : 1);
$remainder = trim($matches[3]);
switch ($matches[1]) {
case 'D':
$this->setRecurType(self::RECUR_DAILY);
break;
case 'W':
$this->setRecurType(self::RECUR_WEEKLY);
$mask = 0;
if (!empty($remainder)) {
$maskdays = array('SU' => Horde_Date::MASK_SUNDAY, 'MO' => Horde_Date::MASK_MONDAY, 'TU' => Horde_Date::MASK_TUESDAY, 'WE' => Horde_Date::MASK_WEDNESDAY, 'TH' => Horde_Date::MASK_THURSDAY, 'FR' => Horde_Date::MASK_FRIDAY, 'SA' => Horde_Date::MASK_SATURDAY);
while (preg_match('/^ ?(' . implode('|', array_keys($maskdays)) . ') ?/', $remainder, $matches)) {
$day = trim($matches[0]);
$remainder = substr($remainder, strlen($matches[0]));
$mask |= $maskdays[$day];
}
$this->setRecurOnDay($mask);
}
if (!$mask) {
// Recur on the day of the week of the original recurrence.
$maskdays = array(Horde_Date::DATE_SUNDAY => Horde_Date::MASK_SUNDAY, Horde_Date::DATE_MONDAY => Horde_Date::MASK_MONDAY, Horde_Date::DATE_TUESDAY => Horde_Date::MASK_TUESDAY, Horde_Date::DATE_WEDNESDAY => Horde_Date::MASK_WEDNESDAY, Horde_Date::DATE_THURSDAY => Horde_Date::MASK_THURSDAY, Horde_Date::DATE_FRIDAY => Horde_Date::MASK_FRIDAY, Horde_Date::DATE_SATURDAY => Horde_Date::MASK_SATURDAY);
$this->setRecurOnDay($maskdays[$this->start->dayOfWeek()]);
}
break;
case 'MP':
$this->setRecurType(self::RECUR_MONTHLY_WEEKDAY);
if (preg_match('/^ \\d([+-])/', $remainder, $matches) && $matches[1] == '-') {
$this->setRecurType(self::RECUR_MONTHLY_LAST_WEEKDAY);
}
break;
case 'MD':
$this->setRecurType(self::RECUR_MONTHLY_DATE);
break;
case 'YM':
$this->setRecurType(self::RECUR_YEARLY_DATE);
break;
case 'YD':
$this->setRecurType(self::RECUR_YEARLY_DAY);
break;
}
// Strip further modifiers.
while ($remainder && !preg_match('/^(#\\d+|\\d{8})($| |T\\d{6})/', $remainder)) {
$remainder = substr($remainder, 1);
}
if (!empty($remainder)) {
if (strpos($remainder, '#') === 0) {
$this->setRecurCount(substr($remainder, 1));
} else {
list($year, $month, $mday, $hour, $min, $sec, $tz) = sscanf($remainder, '%04d%02d%02dT%02d%02d%02d%s');
$this->setRecurEnd(new Horde_Date(array('year' => $year, 'month' => $month, 'mday' => $mday, 'hour' => $hour, 'min' => $min, 'sec' => $sec), $tz == 'Z' ? 'UTC' : $this->start->timezone));
}
}
}