function office_hours_select_process in Office Hours 6.2
Same name and namespace in other branches
- 6 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 88 - 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 (!empty($element['#default_hours'])) {
$hour = _office_hours_mil_to_tf($element['#default_hours']);
list($defhr, $defmin) = explode(":", $hour);
if ($element['#hoursformat']) {
if ($defhr >= 12) {
$defhr -= $defhr != 12 ? 12 : 0;
$ampm = 'pm';
}
elseif ($defhr == 0) {
$defhr += 12;
}
}
else {
$defhr = str_pad($defhr, 2, '0', STR_PAD_LEFT);
}
}
$hours = $element['#hoursformat'] == 1 ? date_hours('g') : date_hours('H');
$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;
}