You are here

function date_repeat_split_rrule in Date 7.2

Same name and namespace in other branches
  1. 5.2 date_repeat/date_repeat.module \date_repeat_split_rrule()
  2. 6.2 date_repeat/date_repeat.module \date_repeat_split_rrule()
  3. 6 date_repeat/date_repeat.module \date_repeat_split_rrule()
  4. 7.3 date_repeat/date_repeat.module \date_repeat_split_rrule()
  5. 7 date_repeat/date_repeat.module \date_repeat_split_rrule()

Parse an iCal rule into a parsed RRULE array and an EXDATE array.

3 calls to date_repeat_split_rrule()
date_repeat_build_dates in date_repeat_field/date_repeat_field.module
Helper function to build repeating dates from a $node_field.
date_repeat_rrule_description in date_repeat/date_repeat.module
Build a description of an iCal rule.
_date_repeat_rrule_process in date_repeat/date_repeat_form.inc
Generate the repeat setting form.

File

date_repeat/date_repeat.module, line 371
Primary hook implementations for the Date Repeat module.

Code

function date_repeat_split_rrule($rrule) {
  $parts = explode("\n", str_replace("\r\n", "\n", $rrule));
  $rrule = array();
  $exceptions = array();
  $additions = array();
  $additions = array();
  foreach ($parts as $part) {
    if (strstr($part, 'RRULE')) {
      $cleanded_part = str_replace('RRULE:', '', $part);
      $rrule = (array) date_ical_parse_rrule('RRULE:', $cleanded_part);
    }
    elseif (strstr($part, 'EXDATE')) {
      $exdate = str_replace('EXDATE:', '', $part);
      $exceptions = (array) date_ical_parse_exceptions('EXDATE:', $exdate);
      unset($exceptions['DATA']);
    }
    elseif (strstr($part, 'RDATE')) {
      $rdate = str_replace('RDATE:', '', $part);
      $additions = (array) date_ical_parse_exceptions('RDATE:', $rdate);
      unset($additions['DATA']);
    }
  }
  return array(
    $rrule,
    $exceptions,
    $additions,
  );
}