I am not sure of a good plan to patch this functionality, so I can allow users to pick the time / date formatting for the opening hours block.
We are trying to show the time(s) in 12 hr format with am/pm, but this code isn't lending itself to the manipulation we were thinking of. Could be my lack of understanding of the preg_match piece, but we would like to expose this to the site configurator so things can be adjusted.
Is this something we might be able to work towards? Maybe on each node type's opening hours tab, we could have a date formatter choice, and choose short/med/long/custom like other modules might allow?
thanks!
-adam
/**
* Format a time value from the database, stripping the seconds.
*/
function opening_hours_format_time($time) {
$matches = array();
preg_match('/^([0-2]?\d):([0-5]?\d)/', $time, $matches);
if (!empty($matches[1]) && !empty($matches[2])) {
return $matches[1] . ':' . $matches[2];
}
return NULL;
}
Comments
Comment #1
nimzie commentedComment #2
jviitamaki commentedI refactored the function a bit and added possibility to alter the output. While this propably isn't the perfect solution at least it allows some kind of date formatting possibility.
Comment #3
jviitamaki commentedComment #4
miklLooks good to me, thanks.
Comment #6
miklFix included in 7.x-1.5-beta3.