? default-timezone-2.patch
? default-timezone-3.patch
? default-timezone-4.patch
? sites/default/files
? sites/default/settings.php
Index: CHANGELOG.txt
===================================================================
RCS file: /cvs/drupal/drupal/CHANGELOG.txt,v
retrieving revision 1.296
diff -u -p -r1.296 CHANGELOG.txt
--- CHANGELOG.txt	26 Jan 2009 14:08:40 -0000	1.296
+++ CHANGELOG.txt	28 Feb 2009 07:22:31 -0000
@@ -59,6 +59,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.270
diff -u -p -r1.270 bootstrap.inc
--- includes/bootstrap.inc	25 Feb 2009 13:49:26 -0000	1.270
+++ includes/bootstrap.inc	28 Feb 2009 07:22:32 -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,20 @@ 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 {
+    $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.869
diff -u -p -r1.869 common.inc
--- includes/common.inc	18 Feb 2009 15:07:26 -0000	1.869
+++ includes/common.inc	28 Feb 2009 07:22:33 -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	28 Feb 2009 07:22:33 -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.86
diff -u -p -r1.86 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	22 Feb 2009 20:12:03 -0000	1.86
+++ modules/simpletest/drupal_web_test_case.php	28 Feb 2009 07:22:34 -0000
@@ -857,6 +857,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();
