? default-timezone-4.patch
? default-timezone-5.patch
? sites/default/files
? sites/default/settings.php
Index: CHANGELOG.txt
===================================================================
RCS file: /cvs/drupal/drupal/CHANGELOG.txt,v
retrieving revision 1.300
diff -u -p -r1.300 CHANGELOG.txt
--- CHANGELOG.txt	15 Mar 2009 01:53:16 -0000	1.300
+++ CHANGELOG.txt	24 Mar 2009 01:09:46 -0000
@@ -61,6 +61,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.272
diff -u -p -r1.272 bootstrap.inc
--- includes/bootstrap.inc	18 Mar 2009 09:21:21 -0000	1.272
+++ includes/bootstrap.inc	24 Mar 2009 01:09:47 -0000
@@ -1178,6 +1178,7 @@ function _drupal_bootstrap($phase) {
     case DRUPAL_BOOTSTRAP_VARIABLES:
       // Initialize configuration variables, using values from settings.php if available.
       $conf = variable_init(isset($conf) ? $conf : array());
+      drupal_date_default_timezone_set();
       break;
 
     case DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE:
@@ -1233,6 +1234,21 @@ function _drupal_bootstrap($phase) {
 }
 
 /**
+ * Set default time zone for date/time functions to the configured time zone.
+ */
+function drupal_date_default_timezone_set() {
+  global $user;
+  if (variable_get('configurable_timezones', 1) && $user->uid && $user->timezone) {
+    $timezone = $user->timezone;
+  }
+  else {
+    // Ignore PHP strict notice if time zone has not yet been set.
+    $timezone = variable_get('date_default_timezone', @date_default_timezone_get());
+  }
+  date_default_timezone_set($timezone);
+}
+
+/**
  * Enables use of the theme system without requiring database access.
  *
  * Loads and initializes the theme system for site installs, updates and when
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.871
diff -u -p -r1.871 common.inc
--- includes/common.inc	17 Mar 2009 22:35:07 -0000	1.871
+++ includes/common.inc	24 Mar 2009 01:09:50 -0000
@@ -1537,13 +1537,7 @@ function format_interval($timestamp, $gr
 function format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL) {
   static $timezones = 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.67
diff -u -p -r1.67 session.inc
--- includes/session.inc	26 Feb 2009 07:30:26 -0000	1.67
+++ includes/session.inc	24 Mar 2009 01:09:50 -0000
@@ -238,6 +238,7 @@ function drupal_session_regenerate() {
     ))
     ->condition('sid', $old_session_id)
     ->execute();
+  drupal_date_default_timezone_set();
 }
 
 /**
Index: modules/simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.91
diff -u -p -r1.91 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	17 Mar 2009 23:26:33 -0000	1.91
+++ modules/simpletest/drupal_web_test_case.php	24 Mar 2009 01:09:52 -0000
@@ -856,6 +856,7 @@ class DrupalWebTestCase {
     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());
 
     // Use temporary files directory with the same prefix as database.
     $this->originalFileDirectory = file_directory_path();
