You are here

function date_repeat_rrule_validate in Date 7

Same name and namespace in other branches
  1. 8 date_repeat/date_repeat_form.inc \date_repeat_rrule_validate()
  2. 5.2 date_repeat/date_repeat_form.inc \date_repeat_rrule_validate()
  3. 6.2 date_repeat/date_repeat_form.inc \date_repeat_rrule_validate()
  4. 6 date_repeat/date_repeat_form.inc \date_repeat_rrule_validate()
  5. 7.3 date_repeat/date_repeat_form.inc \date_repeat_rrule_validate()
  6. 7.2 date_repeat/date_repeat_form.inc \date_repeat_rrule_validate()

Build a RRULE out of the form values.

1 string reference to 'date_repeat_rrule_validate'
date_repeat_element_info in date_repeat/date_repeat.module
Implement hook_element_info().

File

date_repeat/date_repeat_form.inc, line 327
Code to add a date repeat selection form to a date field and create an iCal RRULE from the chosen selections.

Code

function date_repeat_rrule_validate($element, &$form_state) {
  module_load_include('inc', 'date_api', 'date_api_ical');
  $form_values = $form_state['values'];
  $item = $form_values;
  foreach ($element['#parents'] as $key) {
    $item = $item[$key];
  }
  $item = date_repeat_merge($item, $element);
  if (!empty($item['UNTIL']['datetime']) && is_object($item['UNTIL']['datetime'])) {
    $item['UNTIL']['datetime']
      ->setTime(23, 59, 59);
    $item['UNTIL']['datetime']
      ->setTimeZone(new DateTimeZone('UTC'));
    $item['UNTIL']['tz'] = 'UTC';
  }
  $rrule = date_api_ical_build_rrule($item);
  form_set_value($element, $rrule, $form_state);
}