You are here

function office_hours_select_process in Office Hours 6

Same name and namespace in other branches
  1. 6.2 office_hours.elements.inc \office_hours_select_process()

Process the hours selector element.

1 string reference to 'office_hours_select_process'
_office_hours_elements in ./office_hours.elements.inc
Implementation of hook_elements().

File

./office_hours.elements.inc, line 91
office_hours.elements.inc Office hours form elements and their theming and validation. This file is only included during the edit process to reduce memory usage.

Code

function office_hours_select_process($element, $edit, $form_state, $form) {
  $ampm = 'am';
  $defhr = '';
  $defmin = '';
  if (is_numeric($element['#default_hours'])) {
    list($defhr, $defmin, $ampm) = _office_hours_return_defaults($element['#default_hours'], $element['#hoursformat']);
  }
  $hours = $element['#hoursformat'] == 1 ? date_hours('g') : date_hours('H');
  $hours = _office_hours_limit_hours($hours, $element['#limitstart'], $element['#limitend']);
  $minutes = date_minutes('i', FALSE, $element['#granularity']);
  $element['hours'] = array(
    '#type' => 'select',
    '#options' => drupal_map_assoc($hours),
    '#default_value' => isset($defhr) ? $defhr : 0,
  );
  $element['minutes'] = array(
    '#type' => 'select',
    '#options' => drupal_map_assoc($minutes),
    '#default_value' => isset($defmin) ? $defmin : '',
  );
  if ($element['#hoursformat'] == 1) {
    $element['ampm'] = array(
      '#type' => 'select',
      '#options' => date_ampm(),
      '#default_value' => $ampm,
    );
  }
  return $element;
}