function date_popup_process_time in Date 7
Same name and namespace in other branches
- 5.2 date_popup/date_popup.module \date_popup_process_time()
- 6.2 date_popup/date_popup.module \date_popup_process_time()
- 6 date_popup/date_popup.module \date_popup_process_time()
Process the time portion of the element.
1 call to date_popup_process_time()
- date_popup_element_process in date_popup/
date_popup.module - Javascript popup element processing. Add popup attributes to $element.
File
- date_popup/
date_popup.module, line 302 - A module to enable jquery calendar and time entry popups. Requires the Date API.
Code
function date_popup_process_time(&$element) {
$granularity = date_format_order($element['#date_format']);
$has_time = date_has_time($granularity);
if (empty($has_time)) {
return array();
}
$spinner_text = array(
t('Now'),
t('Previous field'),
t('Next field'),
t('Increment'),
t('Decrement'),
);
$settings = array(
'show24Hours' => strpos($element['#date_format'], 'H') !== FALSE ? TRUE : FALSE,
'showSeconds' => in_array('second', $granularity) ? TRUE : FALSE,
'timeSteps' => array(
1,
intval($element['#date_increment']),
in_array('second', $granularity) ? $element['#date_increment'] : 0,
),
'spinnerImage' => '',
'fromTo' => isset($fromto),
);
// Create a unique id for each set of custom settings.
$id = date_popup_js_settings_id($element['#id'], 'timeEntry', $settings);
// Manually build this element and set the value - this will prevent corrupting
// the parent value
$parents = array_merge($element['#parents'], array(
'time',
));
$sub_element = array(
'#type' => 'textfield',
'#default_value' => $element['#value']['time'],
'#id' => $id,
'#size' => 10,
'#maxlength' => 10,
'#attributes' => $element['#attributes'],
'#parents' => $parents,
'#name' => array_shift($parents) . '[' . implode('][', $parents) . ']',
);
$sub_element['#value'] = $sub_element['#default_value'];
// TODO, figure out exactly when we want this description. In many places it is not desired.
$sub_element['#description'] = t('Format: @date', array(
'@date' => date_format_date(date_now(), 'custom', date_popup_time_format($element)),
));
return $sub_element;
}