You are here

function merci_hours_get_open_hours_by_day in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.3

Return array of office hours keyed by day of the week.

3 calls to merci_hours_get_open_hours_by_day()
merci_hours_get_open_hours in merci_hours/merci_hours.module
returns the open and close hours for the given calendar and day of week.
merci_hours_quickset_date_element_set_validate in merci_hours/merci_hours_quickset.module
Validate callback for date form elements with #work_calendar.
merci_hours_time_is_open in merci_hours/merci_hours.module
Determine if we are open during the given time.

File

merci_hours/merci_hours.module, line 417

Code

function merci_hours_get_open_hours_by_day($cal) {
  $hours =& drupal_static(__FUNCTION__, array());
  if (!array_key_exists($cal, $hours)) {
    $wc = merci_hours_instantiate($cal);
    $cal_hours = array();
    foreach ($wc->{MERCI_HOURS_FIELD}[LANGUAGE_NONE] as $timefield) {
      $open = new DateObject($timefield['value']);
      $close = new DateObject($timefield['value2']);
      $day_of_week = $open
        ->format('w');
      if (!array_key_exists($day_of_week, $cal_hours)) {
        $cal_hours[$day_of_week] = array();
      }
      $cal_hours[$day_of_week][] = array(
        'open' => $open,
        'close' => $close,
      );
    }
    $hours[$cal] = $cal_hours;
  }
  return $hours[$cal];
}