function date_popup_process_time in Date 5.2
Same name and namespace in other branches
- 6.2 date_popup/date_popup.module \date_popup_process_time()
- 6 date_popup/date_popup.module \date_popup_process_time()
- 7 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_process in date_popup/
date_popup.module - Javascript popup element processing. Add popup attributes to $element.
File
- date_popup/
date_popup.module, line 264 - A module to enable jquery calendar and time entry popups. Requires the Date API.
Code
function date_popup_process_time(&$element, $edit = NULL, $date = NULL) {
$granularity = $element['#granularity'];
$time_granularity = array_intersect($granularity, array(
'hour',
'minute',
'second',
));
$time_format = date_popup_format_to_popup_time(date_limit_format($element['#date_format'], $time_granularity));
if (empty($time_granularity)) {
return array();
}
$spinner_text = array(
t('Now'),
t('Previous field'),
t('Next field'),
t('Increment'),
t('Decrement'),
);
$settings = "\n" . "show24Hours: " . (strpos($element['#date_format'], 'H') !== FALSE ? 'true' : 'false') . ", \n" . "showSeconds: " . (in_array('second', $granularity) ? 'true' : 'false') . ", \n" . "timeSteps: [1," . $element['#date_increment'] . "," . (in_array('second', $granularity) ? $element['#date_increment'] : 0) . "], \n" . "spinnerImage: ''\n";
// This is just a placeholder to indicate the method to constrain from and to times.
// Not yet implemented.
if ($fromto) {
$settings . +", minTime: (input.id == 'tTo' ? getTime(\$('#tFrom').val()) : null), \n" . "maxTime: (input.id == 'tFrom' ? getTime(\$('#tTo').val()) : null)} ";
}
// Create a unique class for each set of custom settings.
$class = date_popup_js_settings_class('jquery-timeentry', 'timeEntry', $settings);
$sub_element = array(
'#type' => 'textfield',
'#default_value' => (!empty($element['#value']['time']) || !empty($edit['time'])) && is_object($date) ? date_format($date, $time_format) : '',
'#attributes' => array(
'class' => $class,
),
'#size' => 10,
'#maxlength' => 10,
);
// TODO, figure out exactly when we want this description. In many places it is not desired.
$element['#description'] .= t(' @date', array(
'@date' => date($time_format, time()),
));
return $sub_element;
}