You are here

function date_timezone_user_form in Date 6.2

Same name and namespace in other branches
  1. 5.2 date_timezone/date_timezone.module \date_timezone_user_form()
  2. 6 date_timezone/date_timezone.module \date_timezone_user_form()

Create a form for the site timezone names. Display a list of timezone names instead of offsets.

1 call to date_timezone_user_form()
date_timezone_form_alter in date_timezone/date_timezone.module
Implementation of hook_form_alter().

File

date_timezone/date_timezone.module, line 103
This module will make the alter the user and site timezone forms to select a timezone name instead of a timezone offset.

Code

function date_timezone_user_form(&$form) {
  drupal_add_js(drupal_get_path('module', 'date_timezone') . '/date_timezone.js');
  $account = $form['_account']['#value'];
  $form['timezone']['#uid'] = $account->uid;
  $form['timezone']['#element_validate'] = array(
    'date_timezone_update_user',
  );
  $timezone = $account->timezone_name ? $account->timezone_name : variable_get('date_default_timezone_name', NULL);
  $form['timezone']['timezone_name'] = array(
    '#type' => 'select',
    '#title' => t('Default time zone'),
    '#default_value' => $timezone,
    '#options' => date_timezone_names(),
    '#description' => t('Select your current local time. If in doubt, choose the timezone that is closest to your location which has the same rules for daylight saving time. Dates and times throughout this site will be displayed using this time zone.'),
  );

  // Add the JavaScript callback to automatically set the timezone.
  if (empty($timezone)) {
    drupal_add_js('
// Global Killswitch
if (Drupal.jsEnabled) {
  $(document).ready(function() {
    Drupal.setDefaultTimezone();
  });
}', 'inline');
  }
  return $form;
}