function date_locale_get_locale_date_format in Date 6.2
Select locale date format details from database.
Parameters
$languages: An array of language codes.
Return value
An array of date formats.
1 call to date_locale_get_locale_date_format()
- date_locale_init in date_locale/
date_locale.module - Implementation of hook_init().
File
- date_locale/
date_locale.module, line 63 - Enable different locales to have their own date formats.
Code
function date_locale_get_locale_date_format($languages) {
$formats = array();
// Get list of different format types.
$format_types = date_get_format_types();
$short_default = variable_get('date_format_short', 'm/d/Y - H:i');
// Loop through each language until we find one with some date formats
// configured.
foreach ($languages as $language) {
$date_formats = date_format_locale($language);
if (!empty($date_formats)) {
// We have locale-specific date formats, so check for their types. If
// we're missing a type, use the default setting instead.
foreach ($format_types as $type => $type_info) {
if (isset($date_formats[$type])) {
$format = $date_formats[$type];
// If format exists for this language, use it.
if (!empty($format)) {
$formats['date_format_' . $type] = $format;
}
else {
$formats['date_format_' . $type] = variable_get('date_format_' . $type, $short_default);
}
}
}
// Return on the first match.
return $formats;
}
}
// No locale specific formats found, so use defaults.
$system_types = array(
'short',
'medium',
'long',
);
// Handle system types separately as they have defaults if no variable exists.
$formats['date_format_short'] = $short_default;
$formats['date_format_medium'] = variable_get('date_format_medium', 'D, m/d/Y - H:i');
$formats['date_format_long'] = variable_get('date_format_long', 'l, F j, Y - H:i');
// For non-system types, get the default setting, otherwise use the short
// format.
foreach ($format_types as $type => $type_info) {
if (!in_array($type, $system_types)) {
$formats['date_format_' . $type] = variable_get('date_format_' . $type, $short_default);
}
}
return $formats;
}