? sites/all/modules
? sites/default/files
? sites/default/settings.pgsql.php
? sites/default/settings.php
Index: install.php
===================================================================
RCS file: /cvs/drupal/drupal/install.php,v
retrieving revision 1.117
diff -u -p -r1.117 install.php
--- install.php	14 Apr 2008 17:48:33 -0000	1.117
+++ install.php	14 Apr 2008 18:24:42 -0000
@@ -1047,7 +1047,7 @@ function install_configure_form(&$form_s
   $form['server_settings']['date_default_timezone'] = array(
     '#type' => 'select',
     '#title' => st('Default time zone'),
-    '#default_value' => 0,
+    '#default_value' => date_default_timezone_get(),
     '#options' => _system_zonelist(),
     '#description' => st('By default, dates in this site will be displayed in the chosen time zone.'),
     '#weight' => 5,
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.764
diff -u -p -r1.764 common.inc
--- includes/common.inc	14 Apr 2008 17:48:33 -0000	1.764
+++ includes/common.inc	14 Apr 2008 18:24:48 -0000
@@ -1149,17 +1149,19 @@ function format_interval($timestamp, $gr
  *   A translated date string in the requested format.
  */
 function format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL) {
-  if (!isset($timezone)) {
+  static $timezones;
+  if (!$timezone) {
     global $user;
-    if (variable_get('configurable_timezones', 1) && $user->uid && strlen($user->timezone)) {
+    if (variable_get('configurable_timezones', 1) && $user->uid && $user->timezone) {
       $timezone = $user->timezone;
     }
     else {
-      $timezone = variable_get('date_default_timezone', 0);
+      $timezone = variable_get('date_default_timezone', 'UTC');
     }
   }
-
-  $timestamp += $timezone;
+  if (!isset($timezones[$timezone])) {
+    $timezones[$timezone] = timezone_open($timezone);
+  }
 
   switch ($type) {
     case 'small':
@@ -1178,28 +1180,25 @@ function format_date($timestamp, $type =
 
   $max = strlen($format);
   $date = '';
+  $date_time = date_create('@' . $timestamp);
+  date_timezone_set($date_time, $timezones[$timezone]);
+
   for ($i = 0; $i < $max; $i++) {
     $c = $format[$i];
-    if (strpos('AaDlM', $c) !== FALSE) {
-      $date .= t(gmdate($c, $timestamp), array(), $langcode);
+    if (strpos('AaeDlMT', $c) !== FALSE) {
+      $date .= t(date_format($date_time, $c), array(), $langcode);
     }
     else if ($c == 'F') {
       // Special treatment for long month names: May is both an abbreviation
       // and a full month name in English, but other languages have
       // different abbreviations.
-      $date .= trim(t('!long-month-name ' . gmdate($c, $timestamp), array('!long-month-name' => ''), $langcode));
+      $date .= trim(t('!long-month-name ' . date_format($date_time, $c), array('!long-month-name' => ''), $langcode));
     }
-    else if (strpos('BdgGhHiIjLmnsStTUwWYyz', $c) !== FALSE) {
-      $date .= gmdate($c, $timestamp);
+    else if (strpos('BcdGgHhIijLmNnOoPSstUuWwYyZz', $c) !== FALSE) {
+      $date .= date_format($date_time, $c);
     }
     else if ($c == 'r') {
-      $date .= format_date($timestamp - $timezone, 'custom', 'D, d M Y H:i:s O', $timezone, $langcode);
-    }
-    else if ($c == 'O') {
-      $date .= sprintf('%s%02d%02d', ($timezone < 0 ? '-' : '+'), abs($timezone / 3600), abs($timezone % 3600) / 60);
-    }
-    else if ($c == 'Z') {
-      $date .= $timezone;
+      $date .= format_date($timestamp, 'custom', 'D, d M Y H:i:s O', $timezone, $langcode);
     }
     else if ($c == '\\') {
       $date .= $format[++$i];
Index: modules/system/system.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v
retrieving revision 1.70
diff -u -p -r1.70 system.admin.inc
--- modules/system/system.admin.inc	14 Apr 2008 17:48:41 -0000	1.70
+++ modules/system/system.admin.inc	14 Apr 2008 18:24:51 -0000
@@ -1573,7 +1573,7 @@ function system_date_time_settings() {
   $form['locale']['date_default_timezone'] = array(
     '#type' => 'select',
     '#title' => t('Default time zone'),
-    '#default_value' => variable_get('date_default_timezone', 0),
+    '#default_value' => variable_get('date_default_timezone', date_default_timezone_get()),
     '#options' => $zones,
     '#description' => t('Select the default site time zone.')
   );
Index: modules/system/system.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.install,v
retrieving revision 1.247
diff -u -p -r1.247 system.install
--- modules/system/system.install	14 Apr 2008 17:48:41 -0000	1.247
+++ modules/system/system.install	14 Apr 2008 18:24:55 -0000
@@ -2846,6 +2846,23 @@ function system_update_7004(&$sandbox) {
 }
 
 /**
+ * Convert default time zone offset to default time zone name.
+ */
+function system_update_7005() {
+  $ret = array();
+  if ($timezone = variable_get('date_default_timezone_name', NULL)) {
+    variable_set('date_default_timezone', $timezone);
+  }
+  elseif ($timezone = variable_get('date_default_timezone', 0)) {
+    variable_set('date_default_timezone', timezone_name_from_abbr('', intval($timezone), intval(date('I'))));
+  }
+  else {
+    variable_set('date_default_timezone', 'UTC');    
+  }
+  return $ret;
+}
+
+/**
  * @} End of "defgroup updates-6.x-to-7.x"
  * The next series of updates should start at 8000.
  */
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.597
diff -u -p -r1.597 system.module
--- modules/system/system.module	14 Apr 2008 17:48:41 -0000	1.597
+++ modules/system/system.module	14 Apr 2008 18:24:57 -0000
@@ -713,7 +713,7 @@ function system_user($type, $edit, &$use
       $form['timezone']['timezone'] = array(
         '#type' => 'select',
         '#title' => t('Time zone'),
-        '#default_value' => strlen($edit['timezone']) ? $edit['timezone'] : variable_get('date_default_timezone', 0),
+        '#default_value' => $edit['timezone'] ? $edit['timezone'] : variable_get('date_default_timezone', 'UTC'),
         '#options' => $zones,
         '#description' => t('Select your current local time. Dates and times throughout this site will be displayed using this time zone.'),
       );
@@ -2018,11 +2018,12 @@ function system_block_ip_action() {
  */
 function _system_zonelist() {
   $timestamp = time();
-  $zonelist = array(-11, -10, -9.5, -9, -8, -7, -6, -5, -4, -3.5, -3, -2, -1, 0, 1, 2, 3, 3.5, 4, 5, 5.5, 5.75, 6, 6.5, 7, 8, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.75, 13, 14);
+  $zonelist = timezone_identifiers_list();
   $zones = array();
-  foreach ($zonelist as $offset) {
-    $zone = $offset * 3600;
-    $zones[$zone] = format_date($timestamp, 'custom', variable_get('date_format_long', 'l, F j, Y - H:i') . ' O', $zone);
+  foreach ($zonelist as $zone) {
+    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($timestamp, 'custom', variable_get('date_format_long', 'l, F j, Y - H:i') . ' O', $zone)));
+    }
   }
   return $zones;
 }
Index: modules/user/user.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.install,v
retrieving revision 1.10
diff -u -p -r1.10 user.install
--- modules/user/user.install	14 Apr 2008 17:48:43 -0000	1.10
+++ modules/user/user.install	14 Apr 2008 18:24:58 -0000
@@ -191,7 +191,7 @@ function user_schema() {
       ),
       'timezone' => array(
         'type' => 'varchar',
-        'length' => 8,
+        'length' => 32,
         'not null' => FALSE,
         'description' => t("User's timezone."),
       ),
@@ -310,6 +310,30 @@ function user_update_7000(&$sandbox) {
 }
 
 /**
+ * Convert user time zones from time zone offsets to time zone names.
+ */
+function user_update_7001() {
+  $ret = array();
+  db_change_field($ret, 'users', 'timezone', 'timezone', array('type' => 'varchar', 'length' => 32, 'not null' => FALSE, 'description' => t("User's timezone.")));
+  if (db_column_exists('users', 'timezone_name')) {
+    $ret[] = update_sql("UPDATE {users} SET timezone = timezone_name");
+  }
+  else {
+    $result = db_query("SELECT timezone FROM {users} WHERE LENGTH(timezone) > 0 GROUP BY timezone");
+    while ($user_offset = db_fetch_object($result)) {
+      // It is impossible to determine the timezone correctly from the offset alone.
+      // We can throw a little extra data at the problem by also providing the server's 
+      // daylight saving time status; this, however, may not match the user's daylight
+      // saving time status.
+      $timezone = timezone_name_from_abbr('', intval($user_offset->timezone), intval(date('I')));
+      db_query("UPDATE {users} SET timezone = '%s' WHERE timezone = '%s'", $timezone, $user_offset->timezone);
+      $ret[] = array('success' => TRUE, 'query' => check_plain("UPDATE {users} SET timezone = '$timezone' WHERE timezone = '$user_offset->timezone'"));
+    }
+  }
+  return $ret;
+}
+
+/**
  * @} End of "defgroup user-updates-6.x-to-7.x"
  * The next series of updates should start at 8000.
  */
Index: modules/user/user.js
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.js,v
retrieving revision 1.6
diff -u -p -r1.6 user.js
--- modules/user/user.js	12 Sep 2007 18:29:32 -0000	1.6
+++ modules/user/user.js	14 Apr 2008 18:24:58 -0000
@@ -171,8 +171,30 @@ Drupal.evaluatePasswordStrength = functi
  * Set the client's system timezone as default values of form fields.
  */
 Drupal.setDefaultTimezone = function() {
-  var offset = new Date().getTimezoneOffset() * -60;
-  $("#edit-date-default-timezone, #edit-user-register-timezone").val(offset);
+  var matches = Date().match(/\(([A-Z]{3,4})\)/);
+  var abbr = matches ? matches[1] : 0;
+  var dateNow = new Date();
+  var dateJan = new Date(dateNow.getFullYear(), 0, 1, 0, 0, 0, 0);
+  var dateJul = new Date(dateNow.getFullYear(), 6, 1, 0, 0, 0, 0);
+  var offsetNow = dateNow.getTimezoneOffset() * -60;
+  var offsetJan = dateJan.getTimezoneOffset() * -60;
+  var offsetJul = dateJul.getTimezoneOffset() * -60;
+  var offsetMax = Math.max(offsetJan, offsetJul);
+  if (offsetJan == offsetJul) {
+    var dst = '';
+  }
+  else if (offsetMax == offsetNow) {
+    var dst = 1;
+  }
+  else {
+    var dst = 0;
+  }
+  var path = 'user/timezone/'+ Drupal.encodeURIComponent(abbr) +'/'+ Drupal.encodeURIComponent(offsetNow) +'/'+ Drupal.encodeURIComponent(dst);
+  $.getJSON(Drupal.settings.basePath, { q: path }, function (data) {
+    if (data) {
+      $("#edit-date-default-timezone, #edit-user-register-timezone").val(data);
+    }
+  });
 };
 
 /**
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.902
diff -u -p -r1.902 user.module
--- modules/user/user.module	14 Apr 2008 17:48:43 -0000	1.902
+++ modules/user/user.module	14 Apr 2008 18:25:01 -0000
@@ -850,6 +850,14 @@ function user_menu() {
     'file' => 'user.pages.inc',
   );
 
+  $items['user/timezone'] = array(
+    'title' => 'User timezone',
+    'page callback' => 'user_timezone',
+    'access callback' => TRUE,
+    'type' => MENU_CALLBACK,
+    'file' => 'user.pages.inc',
+  );
+
   // Registration and login pages.
   $items['user'] = array(
     'title' => 'User account',
Index: modules/user/user.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.pages.inc,v
retrieving revision 1.13
diff -u -p -r1.13 user.pages.inc
--- modules/user/user.pages.inc	14 Apr 2008 17:48:43 -0000	1.13
+++ modules/user/user.pages.inc	14 Apr 2008 18:25:01 -0000
@@ -22,6 +22,14 @@ function user_autocomplete($string = '')
 }
 
 /**
+ * Menu callback; Retrieve a JSON object containing a suggested timezone name.
+ */
+function user_timezone($abbr = '', $offset = -1, $dst = NULL) {
+  $abbr = $abbr ? $abbr : '';
+  drupal_json(timezone_name_from_abbr($abbr, intval($offset), $dst));
+}
+
+/**
  * Form builder; Request a password reset.
  *
  * @ingroup forms
