You are here

public static function DateiCalParse::parse_rrule in Date 8

Parse an ical repeat rule.

Return value

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

5 calls to DateiCalParse::parse_rrule()
DateiCalParse::parse in date_api/lib/Drupal/date_api/DateiCalParse.php
Returns an array of iCalendar information from an iCalendar file.
DateiCalParse::split_rrule in date_api/lib/Drupal/date_api/DateiCalParse.php
Parse an iCal rule into a parsed RRULE array, along with EXDATE and RDATE arrays.
DateMigrateFieldHandler::prepare in date_migrate/date.migrate.inc
Converts incoming data into the proper field arrays for Date fields.
DateRRuleCalc::__construct in date_repeat/lib/Drupal/date_repeat/DateRRuleCalc.php
Compute dates that match the requested rule, within a specified date range.
date_repeat_build_dates in date_repeat_field/date_repeat_field.module
Helper function to build repeating dates from an $entity field.

File

date_api/lib/Drupal/date_api/DateiCalParse.php, line 692
Parse iCal data.

Class

DateiCalParse
Return an array of iCalendar information from an iCalendar file.

Namespace

Drupal\date_api

Code

public static function parse_rrule($data, $field = 'RRULE:') {
  $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 = self::parse_date($param[1]);
    }
    else {
      $values = explode(',', $param[1]);
    }

    // Treat items differently if they have multiple or single values.
    if (in_array($param[0], array(
      'FREQ',
      'INTERVAL',
      'COUNT',
      'WKST',
    ))) {
      $items[$param[0]] = $param[1];
    }
    else {
      $items[$param[0]] = $values;
    }
  }
  return $items;
}