? sites/default/files
? sites/default/settings.php
Index: CHANGELOG.txt
===================================================================
RCS file: /cvs/drupal/drupal/CHANGELOG.txt,v
retrieving revision 1.317
diff -u -p -r1.317 CHANGELOG.txt
--- CHANGELOG.txt	21 Jul 2009 07:09:46 -0000	1.317
+++ CHANGELOG.txt	24 Jul 2009 00:40:49 -0000
@@ -73,6 +73,8 @@ Drupal 7.0, xxxx-xx-xx (development vers
     * If your site is being upgraded from Drupal 6 and you do not have the
       contributed date or event modules installed, user time zone settings will
       fallback to the system time zone and will have to be reconfigured by each user.
+    * User-configured time zones now serve as the default time zone for PHP
+      date/time functions.
 - Removed ping module:
     * Contributed modules with similar functionality are available.
 - Refactored the "access rules" component of user module:
Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.291
diff -u -p -r1.291 bootstrap.inc
--- includes/bootstrap.inc	22 Jul 2009 04:45:35 -0000	1.291
+++ includes/bootstrap.inc	24 Jul 2009 00:40:50 -0000
@@ -1375,6 +1375,7 @@ function _drupal_bootstrap($phase) {
     case DRUPAL_BOOTSTRAP_VARIABLES:
       // Load variables from the database, but do not overwrite variables set in settings.php.
       $conf = variable_initialize(isset($conf) ? $conf : array());
+      date_default_timezone_set(drupal_get_user_timezone());
       break;
 
     case DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE:
@@ -1436,6 +1437,21 @@ function _drupal_bootstrap($phase) {
 }
 
 /**
+ * Return the time zone of the current user.
+ */
+function drupal_get_user_timezone() {
+  global $user;
+  if (variable_get('configurable_timezones', 1) && $user->uid && $user->timezone) {
+    return $user->timezone;
+  }
+  else {
+    // Ignore PHP strict notice if time zone has not yet been set in the php.ini
+    // configuration.
+    return variable_get('date_default_timezone', @date_default_timezone_get());
+  }
+}
+
+/**
  * Validate the HMAC and timestamp of a user agent header from simpletest.
  */
 function drupal_valid_test_ua($user_agent) {
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.940
diff -u -p -r1.940 common.inc
--- includes/common.inc	23 Jul 2009 21:20:16 -0000	1.940
+++ includes/common.inc	24 Jul 2009 00:40:50 -0000
@@ -1889,13 +1889,7 @@ function format_interval($timestamp, $gr
 function format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL) {
   $timezones = &drupal_static(__FUNCTION__, array());
   if (!isset($timezone)) {
-    global $user;
-    if (variable_get('configurable_timezones', 1) && $user->uid && $user->timezone) {
-      $timezone = $user->timezone;
-    }
-    else {
-      $timezone = variable_get('date_default_timezone', 'UTC');
-    }
+    $timezone = date_default_timezone_get();
   }
   // Store DateTimeZone objects in an array rather than repeatedly
   // contructing identical objects over the life of a request.
Index: includes/session.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/session.inc,v
retrieving revision 1.70
diff -u -p -r1.70 session.inc
--- includes/session.inc	1 Jul 2009 12:47:30 -0000	1.70
+++ includes/session.inc	24 Jul 2009 00:40:50 -0000
@@ -269,6 +269,7 @@ function drupal_session_regenerate() {
       ->condition('sid', $old_session_id)
       ->execute();
   }
+  date_default_timezone_set(drupal_get_user_timezone());
 }
 
 /**
Index: modules/simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.128
diff -u -p -r1.128 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	22 Jul 2009 04:45:35 -0000	1.128
+++ modules/simpletest/drupal_web_test_case.php	24 Jul 2009 00:40:50 -0000
@@ -1077,6 +1077,7 @@ class DrupalWebTestCase extends DrupalTe
     variable_set('install_task', 'profile-finished');
     variable_set('clean_url', $clean_url_original);
     variable_set('site_mail', 'simpletest@example.com');
+    variable_set('date_default_timezone', date_default_timezone_get());
     // Set up English language.
     unset($GLOBALS['conf']['language_default']);
     $language = language_default();
Index: modules/simpletest/tests/common.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/common.test,v
retrieving revision 1.56
diff -u -p -r1.56 common.test
--- modules/simpletest/tests/common.test	15 Jul 2009 17:40:18 -0000	1.56
+++ modules/simpletest/tests/common.test	24 Jul 2009 00:40:50 -0000
@@ -1059,6 +1059,8 @@ class FormatDateUnitTest extends DrupalW
     $user = user_load($test_user->uid, TRUE);
     $real_language = $language->language;
     $language->language = $user->language;
+    // Simulate a Drupal bootstrap with the logged-in user.
+    date_default_timezone_set(drupal_get_user_timezone());
 
     $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', 'en'), 'Sunday, 25-Mar-07 17:00:00 PDT', t('Test a different language.'));
     $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'Europe/London'), 'Monday, 26-Mar-07 01:00:00 BST', t('Test a different time zone.'));
@@ -1071,6 +1073,8 @@ class FormatDateUnitTest extends DrupalW
     // Restore the original user and language, and enable session saving.
     $user = $real_user;
     $language->language = $real_language;
+    // Restore default time zone.
+    date_default_timezone_set(drupal_get_user_timezone());
     drupal_save_session(TRUE);
   }
 }
