Keep track of the system time zone we set HEAD
authorDirk Haun <dirk@haun-online.de>
Sun Sep 20 17:06:57 2009 +0200 (4 months ago)
branchHEAD
changeset 7431ecdf072e268e
parent 7430a053d9023368
child 74323125f1336c8c
Keep track of the system time zone we set
system/classes/timezoneconfig.class.php
     1.1 --- a/system/classes/timezoneconfig.class.php	Sun Sep 20 13:37:16 2009 +0200
     1.2 +++ b/system/classes/timezoneconfig.class.php	Sun Sep 20 17:06:57 2009 +0200
     1.3 @@ -55,23 +55,32 @@
     1.4      {
     1.5          global $_CONF;
     1.6  
     1.7 +        static $system_timezone = '';
     1.8 +
     1.9          if (empty($tz) && !empty($_CONF['timezone'])) {
    1.10              $tz = $_CONF['timezone'];
    1.11          }
    1.12  
    1.13          if (! empty($tz)) {
    1.14 -            if (function_exists('date_default_timezone_set')) {
    1.15 -                if (! @date_default_timezone_set($tz)) {
    1.16 -                    date_default_timezone_set('UTC');
    1.17 -                    COM_errorLog("Timezone '$tz' not valid - using 'UTC' instead", 1);
    1.18 +            if ($tz != $system_timezone) {
    1.19 +                if (function_exists('date_default_timezone_set')) {
    1.20 +                    if (! @date_default_timezone_set($tz)) {
    1.21 +                        date_default_timezone_set('UTC');
    1.22 +                        COM_errorLog("Timezone '$tz' not valid - using 'UTC' instead", 1);
    1.23 +                        $system_timezone = 'UTC';
    1.24 +                    } else {
    1.25 +                        $system_timezone = $tz;
    1.26 +                    }
    1.27 +                } elseif (!ini_get('safe_mode') && function_exists('putenv')) {
    1.28 +                    // aka "Timezone Hack"
    1.29 +                    putenv('TZ=' . $tz);
    1.30 +                    $system_timezone = $tz;
    1.31                  }
    1.32 -            } elseif (!ini_get('safe_mode') && function_exists('putenv')) {
    1.33 -                // aka "Timezone Hack"
    1.34 -                putenv('TZ=' . $tz);
    1.35              }
    1.36          } elseif (function_exists('date_default_timezone_get')) {
    1.37              // this is not ideal but will stop PHP 5.3.0ff from complaining ...
    1.38 -            date_default_timezone_set(@date_default_timezone_get());
    1.39 +            $system_timezone = @date_default_timezone_get();
    1.40 +            date_default_timezone_set($system_timezone);
    1.41          }
    1.42      }
    1.43