function date_timezone_names in Date 6
Same name and namespace in other branches
- 5.2 date_api.module \date_timezone_names()
- 6.2 date_api.module \date_timezone_names()
- 7.3 date_api/date_api.module \date_timezone_names()
- 7 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
5 calls to date_timezone_names()
- date_timezone_process in ./date_api_elements.inc 
- Create a timezone form element.
- date_timezone_site_form in date_timezone/date_timezone.module 
- Override form for the site timezone settings form. Display a list of timezone names instead of offsets and hide the offset value.
- date_timezone_update_5200 in date_timezone/date_timezone.install 
- Get rid of deprecated timezone names.
- date_timezone_user_form in date_timezone/date_timezone.module 
- Override form for the user timezone settings form. Display a list of timezone names instead of offsets and hide the offset value.
- _date_content_generate in date/date_content_generate.inc 
- Implementation of Devel module's hook_content_generate().
File
- ./date_api.module, line 399 
- 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)) {
    $zonenames = array();
    $cached = cache_get('date_timezone_identifiers_list');
    if ($refresh || !($data = $cached->data)) {
      $data = timezone_identifiers_list();
    }
    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] = t($zone);
      }
      else {
        unset($data[$delta]);
      }
    }
    if (!empty($data)) {
      cache_set('date_timezone_identifiers_list', $data);
    }
  }
  $none = array(
    '' => '',
  );
  return !$required ? $none + $zonenames : $zonenames;
}