You are here

function event_zonelist in Event 5.2

Same name and namespace in other branches
  1. 5 event_timezones.inc \event_zonelist()

Returns an array of timezones, either keyed by the zones's numeric ID or by a composite key of ID and offset in seconds.

Parameters

$key a string, either 'id' or 'offset', 'id' is default:

1 call to event_zonelist()
event_form_alter in ./event.module
Implementation of hook_form_alter

File

./event.module, line 2950

Code

function event_zonelist($key = 'id') {
  static $zones;
  if (!is_array($zones)) {
    $result = db_query('SELECT * FROM {event_timezones} ORDER BY timezone');
    $tz_array = array();
    while ($tz = db_fetch_array($result)) {
      $tz_array[$tz['timezone']] = $tz;
    }
    $zones = array();
    $zones['offset'] = array();
    $zones['id'] = array();
    foreach ($tz_array as $id => $zone) {
      $zones['id'][$id] = t($zone['name']);
      if (event_is_dst($zone['dst_region'], _event_user_time())) {
        $offset = explode(':', $zone['offset_dst']);
      }
      else {
        $offset = explode(':', $zone['offset']);
      }
      $offset = $offset[0] * 3600 + $offset[1] * 60 + $offset[2];
      $zones['offset']["{$id}|{$offset}"] = t($zone['name']);
    }
  }
  return $zones[$key];
}