diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2008-11-20 06:56:17 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2008-11-20 06:56:17 +0000 |
commit | 53f53b6db5949c7d8e6b57253987a4eddf7a26ca (patch) | |
tree | ad8ad53d7d351d6dbcf10e9a2f53a53cd6e40850 /modules/system/system.install | |
parent | 07211d4019373820abe9e429ff81656105dcbb9d (diff) | |
download | brdo-53f53b6db5949c7d8e6b57253987a4eddf7a26ca.tar.gz brdo-53f53b6db5949c7d8e6b57253987a4eddf7a26ca.tar.bz2 |
#11077 by mfb, KarenS, macgirvin, and jjkd: Can you say Daylight Savings Time? I bet you didn't think Drupal ever would! :)
Diffstat (limited to 'modules/system/system.install')
-rw-r--r-- | modules/system/system.install | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/modules/system/system.install b/modules/system/system.install index 296e58be6..5d526c1dc 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -3097,7 +3097,47 @@ function system_update_7012() { } /** + * Convert default time zone offset to default time zone name. + */ +function system_update_7013() { + $ret = array(); + $timezone = NULL; + $timezones = system_time_zones(); + // If the contributed Date module set a default time zone name, use this + // setting as the default time zone. + if (($timezone_name = variable_get('date_default_timezone_name', NULL)) && isset($timezones[$timezone_name])) { + $timezone = $timezone_name; + } + // If the contributed Event module has set a default site time zone, look up + // the time zone name and use it as the default time zone. + if (!$timezone && ($timezone_id = variable_get('date_default_timezone_id', 0))) { + try { + $timezone_name = db_result(db_query('SELECT name FROM {event_timezones} WHERE timezone = :timezone_id', array(':timezone_id' => $timezone_id))); + if (($timezone_name = str_replace(' ', '_', $timezone_name)) && isset($timezones[$timezone_name])) { + $timezone = $timezone_name; + } + } + catch (PDOException $e) { + // Ignore error if event_timezones table does not exist or unexpected + // schema found. + } + } + // If the previous default time zone was a non-zero offset, guess the site's + // intended time zone based on that offset and the server's daylight saving + // time status. + if (!$timezone && ($offset = variable_get('date_default_timezone', 0)) && ($timezone_name = timezone_name_from_abbr('', intval($offset), date('I'))) && isset($timezones[$timezone_name])) { + $timezone = $timezone_name; + } + // Otherwise, the default time zone offset was zero, which is UTC. + if (!$timezone) { + $timezone = 'UTC'; + } + variable_set('date_default_timezone', $timezone); + drupal_set_message('The default time zone has been set to <em>' . check_plain($timezone) . '</em>. Please check the ' . l('date and time configuration page', 'admin/settings/date-time') . ' to configure it correctly.', 'warning'); + return $ret; +} + +/** * @} End of "defgroup updates-6.x-to-7.x" * The next series of updates should start at 8000. */ - |