Gets the appropriate date format string for a date type and locale.
$langcode: (optional) String language code for the current locale. This can be a 2 character language code like 'en' and 'fr' or a 5 character language code like 'en-gb' and 'en-us'.
$date_format_id: (optional) String machine name for the date format.
If $date_format_id and $langcode are specified, returns the corresponding date format string. If only $langcode is specified, returns an array of all date format strings for that locale, keyed by the date type. If neither is specified returns FALSE.
function system_date_format_locale($langcode = NULL, $date_format_id = NULL) {
$formats =& drupal_static(__FUNCTION__);
if (!isset($formats[$langcode])) {
$formats[$langcode] = config('locale.config.' . $langcode . '.system.date')
->get('formats');
}
if ($date_format_id && $langcode && !empty($formats[$langcode][$date_format_id])) {
return $formats[$langcode][$date_format_id];
}
elseif ($langcode && !empty($formats[$langcode])) {
return $formats[$langcode];
}
return FALSE;
}