1 system.module | system_user_timezone(&$form, &$form_state) |
Add the time zone field to the user edit and register forms.
File
- core/
modules/ system/ system.module, line 2583 - Configuration system that lets administrators modify the workings of the site.
Code
function system_user_timezone(&$form, &$form_state) {
global $user;
$account = $form['#user'];
$form['region_language']['timezone'] = array(
'#type' => 'select',
'#title' => t('Time zone'),
'#default_value' => isset($account->timezone) ? $account->timezone : ($account->uid == $user->uid ? config_get('system.date', 'default_timezone') : ''),
'#options' => system_time_zones($account->uid != $user->uid),
'#description' => t("This account's preferred time zone for date and time display throughout the site."),
);
if (!isset($account->timezone) && $account->uid == $user->uid && empty($form_state['input']['timezone'])) {
$form['region_language']['timezone']['#attributes'] = array('class' => array('timezone-detect'));
backdrop_add_js('core/misc/timezone.js');
}
}