function date_format_locale in Date 6.2
Get the appropriate date format for a type and locale.
Parameters
$langcode: Language code for the current locale. This can be a 2 character language code like 'en', 'fr', or a longer 5 character code like 'en-gb'.
$type: Date format type: short, medium, long, custom.
$reset: Whether or not to reset this function's internal cache (defaults to FALSE).
Return value
The format string, or NULL if no matching format found.
3 calls to date_format_locale()
- date_formats_rebuild in ./
date_api.module - Resets the database cache of date formats, and saves all new date formats to the database.
- date_locale_format_form in date_locale/
date_locale.module - Display list of enabled languages to configure date formats for.
- date_locale_get_locale_date_format in date_locale/
date_locale.module - Select locale date format details from database.
4 string references to 'date_format_locale'
- date_api_update_6002 in ./
date_api.install - Create new date format tables.
- date_api_update_6003 in ./
date_api.install - date_format_save in ./
date_api.module - Save a date format to the database.
- date_locale_locale_format_save in date_locale/
date_locale.module - Save locale specific date formats to the database.
File
- ./
date_api.module, line 2224 - 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_format_locale($langcode = NULL, $type = NULL, $reset = FALSE) {
static $formats;
if ($reset || empty($formats)) {
$formats = array();
$result = db_query("SELECT format, type, language FROM {date_format_locale}");
while ($object = db_fetch_object($result)) {
if (!isset($formats[$object->language])) {
$formats[$object->language] = array();
}
$formats[$object->language][$object->type] = $object->format;
}
}
if ($type && $langcode && !empty($formats[$langcode][$type])) {
return $formats[$langcode][$type];
}
elseif ($langcode && !empty($formats[$langcode])) {
return $formats[$langcode];
}
return FALSE;
}