function date_timezone_update_site in Date 6.2
Same name and namespace in other branches
- 5.2 date_timezone/date_timezone.module \date_timezone_update_site()
- 6 date_timezone/date_timezone.module \date_timezone_update_site()
Callback from site timezone settings form to update site timezone info. When the timezone name is updated, update the offset as well.
1 string reference to 'date_timezone_update_site'
- date_timezone_site_form in date_timezone/
date_timezone.module - Create a form for the site timezone names. Display a list of timezone names instead of offsets.
File
- date_timezone/
date_timezone.module, line 155 - 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_update_site($element, &$form_state) {
$timezone = $element['date_default_timezone_name']['#value'];
if (empty($timezone)) {
$offset = $element['date_default_timezone_name']['#offset'];
}
else {
variable_set('date_default_timezone_name', $timezone);
$date = date_make_date('now', $timezone);
$offset = date_offset_get($date);
}
// Reset the original form to the expected value.
if (module_exists('event') && db_table_exists('event_timezones')) {
$event_zone = date_event_zonelist_by_name(str_replace('_', ' ', $timezone));
// The event module will update the timezone and zone id, using this value.
if (!empty($event_zone['timezone'])) {
form_set_value($element['date_default_timezone'], $event_zone['timezone'] . '|' . $offset, $form_state);
}
else {
form_set_value($element['date_default_timezone'], $offset, $form_state);
}
}
else {
form_set_value($element['date_default_timezone'], $offset, $form_state);
}
}