You are here

function availability_calendar_month_header in Availability Calendars 7.5

Same name and namespace in other branches
  1. 7.3 availability_calendar.theme.inc \availability_calendar_month_header()
  2. 7.4 availability_calendar.theme.inc \availability_calendar_month_header()

Helper function that returns the header row containing the names of the days.

The order depends on the setting 'first_day_of_week'. The output is either the abbreviated day name or just the first letter of that, depending on the setting 'show_only_first_letter'

Parameters

array $settings:

Return value

array

1 call to availability_calendar_month_header()
theme_availability_calendar_month in ./availability_calendar.theme.inc
Themes the calendar for a given month.

File

./availability_calendar.theme.inc, line 266

Code

function availability_calendar_month_header($settings) {

  // Index of this array is the ISO-8601 numeric representation of the day of
  // the week modulo 7.
  $day_names_abbr = array(
    t('Sun'),
    t('Mon'),
    t('Tue'),
    t('Wed'),
    t('Thu'),
    t('Fri'),
    t('Sat'),
  );

  // Container for header row.
  $headers = array();
  for ($i = 0; $i < 7; $i++) {
    $header = $day_names_abbr[($settings['first_day_of_week'] + $i) % 7];
    if ($settings['show_only_first_letter']) {
      $header = drupal_substr($header, 0, 1);
    }
    $headers[] = $header;
  }
  return $headers;
}