function _eloqua_form_url_map_time in Eloqua 6
Convert url time to form time The time must be a 24 hour format
Parameters
$value:
$element:
Return value
void
File
- ./
eloqua.module, line 547
Code
function _eloqua_form_url_map_time($value, &$element) {
$split = explode(':', $value);
// Validate the format
if (count($split) != 2 || !is_numeric($split[0]) || !is_numeric($split[1])) {
return;
}
$split[0] = (int) $split[0];
$split[1] = (int) $split[1];
// Validate the ranges
if ($split[0] > 23 || $split[1] > 59 || $split[1] < 0 || $split[0] < 0) {
return;
}
$hour = $split[0];
$minute = $split[1];
// If the form is 12-hr, convert
if (array_key_exists('ampm', $element)) {
$ampm = $hour >= 12 ? 'pm' : 'am';
$element['ampm']['#default_value'] = $ampm;
$hour = $hour > 12 || $hour == 0 ? abs($hour - 12) : $hour;
}
$element['hour']['#default_value'] = $hour;
$element['minute']['#default_value'] = $minute;
}