You are here

function date_ical_parse_rrule in Date 7

Same name and namespace in other branches
  1. 5.2 date_api_ical.inc \date_ical_parse_rrule()
  2. 6.2 date_api_ical.inc \date_ical_parse_rrule()
  3. 6 date_api_ical.inc \date_ical_parse_rrule()
  4. 7.3 date_api/date_api_ical.inc \date_ical_parse_rrule()
  5. 7.2 date_api/date_api_ical.inc \date_ical_parse_rrule()

Parse an ical repeat rule.

Return value

array Array in the form of PROPERTY => array(VALUES) PROPERTIES include FREQ, INTERVAL, COUNT, BYDAY, BYMONTH, BYYEAR, UNTIL

3 calls to date_ical_parse_rrule()
date_ical_parse in date_api/date_api_ical.inc
Return an array of iCalendar information from an iCalendar file.
date_repeat_split_rrule in date_repeat/date_repeat.module
Parse an iCal rule into a parsed RRULE array and an EXDATE array.
_date_repeat_calc in date_repeat/date_repeat_calc.inc
Private implementation of date_repeat_calc().

File

date_api/date_api_ical.inc, line 437
Parse iCal data.

Code

function date_ical_parse_rrule($field, $data) {
  $data = preg_replace("/RRULE.*:/", '', $data);
  $items = array(
    'DATA' => $data,
  );
  $rrule = explode(';', $data);
  foreach ($rrule as $key => $value) {
    $param = explode('=', $value);

    // Must be some kind of invalid data.
    if (count($param) != 2) {
      continue;
    }
    if ($param[0] == 'UNTIL') {
      $values = date_ical_parse_date('', $param[1]);
    }
    else {
      $values = explode(',', $param[1]);
    }

    // Different treatment for items that can have multiple values and those that cannot.
    if (in_array($param[0], array(
      'FREQ',
      'INTERVAL',
      'COUNT',
      'WKST',
    ))) {
      $items[$param[0]] = $param[1];
    }
    else {
      $items[$param[0]] = $values;
    }
  }
  return $items;
}