You are here

function _office_hours_field_widget_time_parse in Office Hours 7

1 call to _office_hours_field_widget_time_parse()
_office_hours_select_value_callback in includes/office_hours.elements.inc
Callback for office_hours_select element.

File

./office_hours.module, line 202
Creates a field and widget for inserting working or office hours per day

Code

function _office_hours_field_widget_time_parse($time, $hoursformat) {
  $hour = '';
  $min = '';
  $ampm = 'am';
  if (is_numeric($time)) {
    $timeformat = $hoursformat == 1 ? 'g:i:a' : 'H:i:a';

    // 12hrs or 24hrs
    $time = _office_hours_time_format($time, $timeformat);
    list($hour, $min, $ampm) = explode(':', $time);
    $hour = $hour * 100;
  }
  $result = array(
    'hour' => $hour,
    'minute' => $min,
    'ampm' => $ampm,
  );
  return $result;
}