You are here

function date_week_days_abbr in Date 7.2

Same name and namespace in other branches
  1. 5.2 date_api.module \date_week_days_abbr()
  2. 6.2 date_api.module \date_week_days_abbr()
  3. 6 date_api.module \date_week_days_abbr()
  4. 7.3 date_api/date_api.module \date_week_days_abbr()
  5. 7 date_api/date_api.module \date_week_days_abbr()

Constructs a translated array of week day abbreviations.

Parameters

bool $required: (optional) If FALSE, the returned array will include a blank value. Defaults to FALSE.

bool $refresh: (optional) Whether to refresh the list. Defaults to TRUE.

int $length: (optional) The length of the abbreviation. Defaults to 3.

Return value

array An array of week day abbreviations

2 calls to date_week_days_abbr()
DateApiTestCase::testDateApi in date_api/tests/DateApiTestCase.test
Test date_format_date().
date_day_of_week_name in date_api/date_api.module
Returns translated name of the day of week for a given date.

File

date_api/date_api.module, line 1311
This module will make the date API available to other modules.

Code

function date_week_days_abbr($required = FALSE, $refresh = TRUE, $length = 3) {
  $weekdays = array();
  switch ($length) {
    case 1:
      $context = 'day_abbr1';
      break;
    case 2:
      $context = 'day_abbr2';
      break;
    default:
      $context = '';
  }
  foreach (date_week_days_untranslated() as $key => $day) {
    $weekdays[$key] = t(substr($day, 0, $length), array(), array(
      'context' => $context,
    ));
  }
  $none = array(
    '' => '',
  );
  return !$required ? $none + $weekdays : $weekdays;
}