You are here

function date_t in Date 6.2

Same name and namespace in other branches
  1. 5.2 date_api.module \date_t()
  2. 6 date_api.module \date_t()

A function to translate ambiguous short date strings.

Example: Pass in 'Monday', 'day_abbr' and get the translated abbreviation for Monday.

Parameters

string $string:

string $context:

int $langcode:

Return value

translated value of the string

24 calls to date_t()
date-navigation.tpl.php in theme/date-navigation.tpl.php
Template to display date navigation links.
date_ampm in ./date_api.module
An array of am and pm options.
date_api_argument_handler::options_form in includes/date_api_argument_handler.inc
Add a form element to select date_fields for this argument.
date_format_date in ./date_api.module
Reworked from Drupal's format_date function to handle pre-1970 and post-2038 dates and accept a date object instead of a timestamp as input.
date_granularity_names in ./date_api.module
Array of granularity options and their labels

... See full list

File

./date_api.module, line 631
This module will make the date API available to other modules. Designed to provide a light but flexible assortment of functions and constants, with more functionality in additional files that are not loaded unless other modules specifically include them.

Code

function date_t($string, $context, $langcode = NULL) {
  static $replace = array();
  if (empty($replace[$langcode])) {

    // The function to create the date string arrays is kept separate
    // so those arrays can be directly accessed by other functions.
    date_t_strings($replace, $langcode);
  }
  switch ($context) {
    case 'day_name':
    case 'day_abbr':
    case 'day_abbr1':
    case 'day_abbr2':
      $untranslated = array_flip(date_week_days_untranslated());
      break;
    case 'month_name':
    case 'month_abbr':
      $untranslated = array_flip(date_month_names_untranslated());
      break;
    case 'ampm':
      $untranslated = array_flip(array(
        'am',
        'pm',
        'AM',
        'PM',
      ));
      break;
    case 'datetime':
      $untranslated = array_flip(array(
        'Year',
        'Month',
        'Day',
        'Week',
        'Hour',
        'Minute',
        'Second',
        'All Day',
        'All day',
      ));
      break;
    case 'datetime_plural':
      $untranslated = array_flip(array(
        'Years',
        'Months',
        'Days',
        'Weeks',
        'Hours',
        'Minutes',
        'Seconds',
      ));
      break;
    case 'date_order':
      $untranslated = array_flip(array(
        'Every',
        'First',
        'Second',
        'Third',
        'Fourth',
        'Fifth',
      ));
      break;
    case 'date_order_reverse':
      $untranslated = array_flip(array(
        '',
        'Last',
        'Next to last',
        'Third from last',
        'Fourth from last',
        'Fifth from last',
      ));
      break;
    case 'date_nav':
      $untranslated = array_flip(array(
        'Prev',
        'Next',
        'Today',
      ));
      break;
  }
  $pos = $untranslated[$string];
  return $replace[$langcode][$context][$pos];
}