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

nimzie’s picture

Issue summary: View changes
jviitamaki’s picture

StatusFileSize
new657 bytes

I 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.

jviitamaki’s picture

Status: Active » Needs review
mikl’s picture

Version: 7.x-1.4 » 7.x-1.x-dev
Status: Needs review » Fixed

Looks good to me, thanks.

  • mikl committed e831379 on 7.x-1.x authored by GloGi
    Issue #2388405 by GloGi, nimzie: Provide Formatting Options for Opening...
mikl’s picture

Version: 7.x-1.x-dev » 7.x-1.5-beta3

Fix included in 7.x-1.5-beta3.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.