--- d7.timezone32.patch 2008-11-03 01:34:10.397670500 +0100 +++ drupal.timezone.patch 2008-11-03 01:35:47.235222500 +0100 @@ -44,7 +44,7 @@ retrieving revision 1.815 diff -u -p -r1.815 common.inc --- includes/common.inc 1 Nov 2008 21:21:34 -0000 1.815 -+++ includes/common.inc 3 Nov 2008 00:16:14 -0000 ++++ includes/common.inc 2 Nov 2008 23:41:10 -0000 @@ -1282,7 +1282,7 @@ function format_interval($timestamp, $gr * before a character to avoid interpreting the character as part of a date * format. @@ -58,9 +58,8 @@ * A translated date string in the requested format. */ function format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL) { -- if (!isset($timezone)) { + static $timezones = array(); -+ if (!$timezone) { + if (!isset($timezone)) { global $user; - if (variable_get('configurable_timezones', 1) && $user->uid && strlen($user->timezone)) { + if (variable_get('configurable_timezones', 1) && $user->uid && $user->timezone) { @@ -73,7 +72,7 @@ } - - $timestamp += $timezone; -+ // Store DateTimeZone objects in an array rather than repeatedly ++ // Store DateTimeZone objects in an array rather than repeatedly + // contructing identical objects over the life of a request. + if (!isset($timezones[$timezone])) { + $timezones[$timezone] = timezone_open($timezone); @@ -143,8 +142,8 @@ retrieving revision 1.102 diff -u -p -r1.102 system.admin.inc --- modules/system/system.admin.inc 16 Oct 2008 20:23:08 -0000 1.102 -+++ modules/system/system.admin.inc 3 Nov 2008 00:16:14 -0000 -@@ -1567,12 +1567,25 @@ function system_date_time_settings() { ++++ modules/system/system.admin.inc 2 Nov 2008 23:42:53 -0000 +@@ -1567,19 +1567,11 @@ function system_date_time_settings() { $form['locale']['date_default_timezone'] = array( '#type' => 'select', '#title' => t('Default time zone'), @@ -155,66 +154,60 @@ ); - $form['locale']['configurable_timezones'] = array( -+ $form['locale']['date_first_day'] = array( -+ '#type' => 'select', -+ '#title' => t('First day of week'), -+ '#default_value' => variable_get('date_first_day', 0), -+ '#options' => array(0 => t('Sunday'), 1 => t('Monday'), 2 => t('Tuesday'), 3 => t('Wednesday'), 4 => t('Thursday'), 5 => t('Friday'), 6 => t('Saturday')), -+ '#description' => t('The first day of the week for calendar views.') -+ ); -+ +- '#type' => 'radios', +- '#title' => t('User-configurable time zones'), +- '#default_value' => variable_get('configurable_timezones', 1), +- '#options' => array(t('Disabled'), t('Enabled')), +- '#description' => t('When enabled, users can set their own time zone and dates will be displayed accordingly.') +- ); +- + $form['locale']['date_first_day'] = array( + '#type' => 'select', + '#title' => t('First day of week'), +@@ -1588,6 +1580,35 @@ function system_date_time_settings() { + '#description' => t('The first day of the week for calendar views.') + ); + + $form['timezone'] = array( + '#type' => 'fieldset', -+ '#title' => t('User-configurable time zones'), ++ '#title' => t('Time zone handling'), + ); + + $form['timezone']['configurable_timezones'] = array( - '#type' => 'radios', - '#title' => t('User-configurable time zones'), - '#default_value' => variable_get('configurable_timezones', 1), -@@ -1580,12 +1593,20 @@ function system_date_time_settings() { - '#description' => t('When enabled, users can set their own time zone and dates will be displayed accordingly.') - ); - -- $form['locale']['date_first_day'] = array( -- '#type' => 'select', -- '#title' => t('First day of week'), -- '#default_value' => variable_get('date_first_day', 0), -- '#options' => array(0 => t('Sunday'), 1 => t('Monday'), 2 => t('Tuesday'), 3 => t('Wednesday'), 4 => t('Thursday'), 5 => t('Friday'), 6 => t('Saturday')), -- '#description' => t('The first day of the week for calendar views.') -+ $form['timezone']['user_default_timezone'] = array( + '#type' => 'radios', -+ '#title' => t('User time zone defaults'), -+ '#default_value' => variable_get('user_default_timezone', 0), ++ '#title' => t('User-configurable time zones'), ++ '#default_value' => variable_get('configurable_timezones', 1), ++ '#options' => array(t('Disabled'), t('Enabled')), ++ '#description' => t('When enabled, users can set their own time zone and dates will be displayed accordingly.') ++ ); ++ ++ $form['timezone']['user_default_timezone'] = array( ++ '#type' => 'radios', ++ '#title' => t('User time zone defaults'), ++ '#default_value' => variable_get('user_default_timezone', 0), + '#options' => array(t('New users will be set to the default time zone at registration.'), t('New users will get an empty time zone at registration.'), t('New users will select their own time zone at registration.')), + '#description' => t('Method for setting user time zones at registration when user-configurable time zones are enabled. This only affects the initial time zone setting for a new registration, users will be able to change their time zone any time they edit their account.') + ); + + $form['timezone']['empty_timezone_message'] = array( -+ '#type' => 'radios', -+ '#title' => t('Empty user time zones'), -+ '#default_value' => variable_get('empty_timezone_message', 0), ++ '#type' => 'radios', ++ '#title' => t('Empty user time zones'), ++ '#default_value' => variable_get('empty_timezone_message', 0), + '#options' => array(t('Ignore empty user time zones.'), t('Remind users at login if their time zone is not set.')), + '#description' => t('Handling for empty user time zones when user-configurable time zones are enabled. Use this option to help ensure that users set the correct time zone.') - ); - ++ ); ++ $form['date_formats'] = array( + '#type' => 'fieldset', + '#title' => t('Formatting'), Index: modules/system/system.install =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.install,v retrieving revision 1.275 diff -u -p -r1.275 system.install --- modules/system/system.install 2 Nov 2008 17:56:20 -0000 1.275 -+++ modules/system/system.install 3 Nov 2008 00:16:15 -0000 -@@ -3033,7 +3033,6 @@ function system_update_7007() { - return $ret; - } - -- - /** - * Use the poll_choice primary key to record votes in poll_votes rather than - * the choice order. Rename chorder to weight. -@@ -3115,7 +3114,37 @@ function system_update_7012() { ++++ modules/system/system.install 3 Nov 2008 00:12:19 -0000 +@@ -3115,6 +3115,37 @@ function system_update_7012() { } /** @@ -222,7 +215,7 @@ + */ +function system_update_7013() { + $ret = array(); -+ // If the contributed Date module set a default time zone name, use ++ // If the contributed Date module set a default time zone name, use + // this setting as the default time zone. + if ($timezone = variable_get('date_default_timezone_name', NULL)) { + variable_set('date_default_timezone', $timezone); @@ -234,8 +227,8 @@ + $timezone = str_replace(' ', '_', $timezone); + variable_set('date_default_timezone', $timezone); + } -+ // 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 ++ // 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. + elseif ($timezone = variable_get('date_default_timezone', 0)) { + variable_set('date_default_timezone', timezone_name_from_abbr('', intval($timezone), intval(date('I')))); @@ -252,14 +245,13 @@ * @} End of "defgroup updates-6.x-to-7.x" * The next series of updates should start at 8000. */ -- Index: modules/system/system.js =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.js,v retrieving revision 1.16 diff -u -p -r1.16 system.js --- modules/system/system.js 29 Oct 2008 10:01:27 -0000 1.16 -+++ modules/system/system.js 3 Nov 2008 00:16:15 -0000 ++++ modules/system/system.js 2 Nov 2008 23:57:27 -0000 @@ -117,3 +117,53 @@ Drupal.behaviors.dateTime = { $('select.date-format', context).trigger('change'); } @@ -304,11 +296,11 @@ + var isDaylightSavingTime = 0; + } + + // Submit request to the system/timezone callback and set the form field + // to the response time zone. + var path = 'system/timezone/' + abbreviation + '/' + offsetNow + '/' + isDaylightSavingTime; + // The client date is passed to the callback for debugging purposes. -+ $.getJSON(Drupal.settings.basePath, { q: path, date: dateString }, function (data) { ++ $.getJSON(Drupal.settings.basePath, {q: path, date: dateString}, function(data) { + if (data) { + $("#edit-date-default-timezone, #edit-timezone").val(data); + } @@ -343,7 +335,7 @@ 'page callback' => 'drupal_get_form', 'page arguments' => array('system_date_time_settings'), 'access arguments' => array('administer site configuration'), -@@ -737,29 +743,72 @@ function system_preprocess_page(&$variab +@@ -737,29 +743,68 @@ function system_preprocess_page(&$variab function system_user_form(&$edit, &$user, $category = NULL) { if ($category == 'account') { $form['theme_select'] = system_theme_select_form(t('Selecting a different theme will change the look and feel of the site.'), isset($edit['theme']) ? $edit['theme'] : NULL, 2); @@ -393,7 +385,7 @@ +function system_user_login(&$edit, &$user, $category = NULL) { + // If the user has a NULL time zone, notify them to set a time zone. + if (!$user->timezone && variable_get('configurable_timezones', 1) && variable_get('empty_timezone_message', 0)) { -+ drupal_set_message(t('Please configure your account time zone setting.', array('@user-edit' => url("user/$user->uid/edit", array('query' => drupal_get_destination(), 'fragment' => 'edit-timezone'))))); ++ drupal_set_message(t('Please configure your account time zone setting.', array('!user-edit' => url("user/$user->uid/edit", array('query' => drupal_get_destination(), 'fragment' => 'edit-timezone'))))); + } +} + @@ -418,11 +410,7 @@ + if (!$edit['timezone'] && $edit['uid'] == $user->uid) { + $form['timezone']['#description'] = t('Your time zone setting will be automatically detected if possible. Please confirm the selection and click save.'); + drupal_add_js(drupal_get_path('module', 'system') . '/system.js'); -+ drupal_add_js('if (Drupal.jsEnabled) { -+ $(document).ready(function() { -+ Drupal.setDefaultTimezone(); -+ }); -+ }', 'inline'); ++ drupal_add_js('$(Drupal.setDefaultTimezone);', 'inline'); + } +} + @@ -430,7 +418,7 @@ * Implementation of hook_block(). * * Generate a block with a promotional link to Drupal.org. -@@ -2060,14 +2109,20 @@ function system_block_ip_action() { +@@ -2060,14 +2105,20 @@ function system_block_ip_action() { /** * Generate an array of time zones and their local time&date. @@ -449,21 +437,20 @@ + $zonelist = timezone_identifiers_list(); + $zones = $blank ? array('' => t('- None selected -')) : array(); + foreach ($zonelist as $zone) { -+ // Because many time zones exist in PHP only for backward -+ // compatibility reasons and should not be used, the list is -+ // filtered by a regular expression. ++ // Because many time zones exist in PHP only for backward compatibility ++ // reasons and should not be used, the list is filtered by a regular ++ // expression. + if (preg_match('!^((Africa|America|Antarctica|Arctic|Asia|Atlantic|Australia|Europe|Indian|Pacific)/|UTC$)!', $zone)) { + $zones[$zone] = t('@zone: @date', array('@zone' => t($zone), '@date' => format_date(REQUEST_TIME, 'custom', variable_get('date_format_long', 'l, F j, Y - H:i') . ' O', $zone))); + } } return $zones; } -@@ -2099,6 +2154,22 @@ function system_check_http_request() { +@@ -2099,6 +2150,22 @@ function system_check_http_request() { } /** -+ * Menu callback; Retrieve a JSON object containing a suggested time -+ * zone name. ++ * Menu callback. Retrieve a JSON object containing a suggested time zone name. + */ +function system_timezone($abbreviation = '', $offset = -1, $is_daylight_saving_time = NULL) { + // An abbreviation of "0" passed in the callback arguments should be @@ -475,6 +462,7 @@ + // Log a debug message. + watchdog('timezone', 'Detected time zone: %timezone; client date: %date; abbreviation: %abbreviation; offset: %offset; daylight saving time: %is_daylight_saving_time.', array('%timezone' => $timezone, '%date' => $date, '%abbreviation' => $abbreviation, '%offset' => $offset, '%is_daylight_saving_time' => $is_daylight_saving_time)); + drupal_json($timezone); ++ exit; +} + +/**