You are here

function date_month_names_abbr in Date 7.2

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

Constructs a translated array of month name abbreviations.

Parameters

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

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

Return value

array An array of month abbreviations.

2 calls to date_month_names_abbr()
DateObject::parse in date_api/date_api.module
Converts a date string into a date object.
_date_repeat_rrule_process in date_repeat/date_repeat_form.inc
Generate the repeat setting form.
1 string reference to 'date_month_names_abbr'
date_parts_element in date_api/date_api_elements.inc
Creates form elements for one or more date parts.

File

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

Code

function date_month_names_abbr($required = FALSE, $length = 3) {
  $month_names = array();
  foreach (date_month_names_untranslated() as $key => $month) {
    if ($length == 3) {
      $month_names[$key] = t(substr($month, 0, $length), array());
    }
    else {
      $month_names[$key] = t(substr($month, 0, $length), array(), array(
        'context' => 'month_abbr',
      ));
    }
  }
  $none = array(
    '' => '',
  );
  return !$required ? $none + $month_names : $month_names;
}