function date_timezone_names in Date 7
Same name and namespace in other branches
- 5.2 date_api.module \date_timezone_names()
- 6.2 date_api.module \date_timezone_names()
- 6 date_api.module \date_timezone_names()
- 7.3 date_api/date_api.module \date_timezone_names()
- 7.2 date_api/date_api.module \date_timezone_names()
A translated array of timezone names. Cache the untranslated array, make the translated array a static variable.
Parameters
$required: If not required, returned array will include a blank value.
Return value
an array of timezone names
3 calls to date_timezone_names()
- date_devel_generate in ./
date.devel_generate.inc - Implementation of Devel module's hook_content_generate().
- date_timezone_element_process in date_api/
date_api_elements.inc - Create a timezone form element.
- date_timezone_is_valid in date_api/
date_api.module
File
- date_api/
date_api.module, line 1111 - 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_timezone_names($required = FALSE, $refresh = FALSE) {
static $zonenames;
if (empty($zonenames) || $refresh) {
$cached = cache_get('date_timezone_identifiers_list');
$zonenames = !empty($cached) ? $cached->data : array();
if ($refresh || empty($cached) || empty($zonenames)) {
$data = timezone_identifiers_list();
asort($data);
foreach ($data as $delta => $zone) {
// Because many time zones exist in PHP only for backward
// compatibility reasons and should not be used, the list is
// filtered by a regular expression.
if (preg_match('!^((Africa|America|Antarctica|Arctic|Asia|Atlantic|Australia|Europe|Indian|Pacific)/|UTC$)!', $zone)) {
$zonenames[$zone] = $zone;
}
}
if (!empty($zonenames)) {
cache_set('date_timezone_identifiers_list', $zonenames);
}
}
foreach ($zonenames as $zone) {
$zonenames[$zone] = t('!timezone', array(
'!timezone' => $zone,
));
}
}
$none = array(
'' => '',
);
return !$required ? $none + $zonenames : $zonenames;
}