? default-timezone-2.patch
? default-timezone-3.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	17 Feb 2009 05:18:25 -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.269
diff -u -p -r1.269 bootstrap.inc
--- includes/bootstrap.inc	31 Jan 2009 16:50:56 -0000	1.269
+++ includes/bootstrap.inc	17 Feb 2009 05:18:26 -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) {
 }
 
 /**
+ * Sets 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.867
diff -u -p -r1.867 common.inc
--- includes/common.inc	13 Feb 2009 04:43:00 -0000	1.867
+++ includes/common.inc	17 Feb 2009 05:18:27 -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.65
diff -u -p -r1.65 session.inc
--- includes/session.inc	19 Jan 2009 10:46:50 -0000	1.65
+++ includes/session.inc	17 Feb 2009 05:18:27 -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.84
diff -u -p -r1.84 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	13 Feb 2009 00:39:01 -0000	1.84
+++ modules/simpletest/drupal_web_test_case.php	17 Feb 2009 05:18:27 -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();
