]> git.wh0rd.org - tt-rss.git/commitdiff
do not store tz offset in global, store timezone object instead
authorAndrew Dolgov <fox@fakecake.org>
Fri, 26 Apr 2013 04:50:22 +0000 (08:50 +0400)
committerAndrew Dolgov <fox@fakecake.org>
Fri, 26 Apr 2013 04:50:22 +0000 (08:50 +0400)
include/functions.php

index 8ecdb71e5ae2e2f43b6173a06efece617efbb566..b54187e18b1c548b34ccc86523c29311d8c6f48d 100644 (file)
 
        require_once 'lib/pubsubhubbub/publisher.php';
 
-       $tz_offset = -1;
-       $utc_tz = new DateTimeZone('UTC');
        $schema_version = false;
 
        /**
                if (!$timestamp) $timestamp = '1970-01-01 0:00';
 
                global $utc_tz;
-               global $tz_offset;
+               global $user_tz;
+
+               if (!$utc_tz) $utc_tz = new DateTimeZone('UTC');
 
                $timestamp = substr($timestamp, 0, 19);
 
                # We store date in UTC internally
                $dt = new DateTime($timestamp, $utc_tz);
 
-               if ($tz_offset == -1) {
-
-                       $user_tz_string = get_pref('USER_TIMEZONE', $owner_uid);
-
-                       try {
-                               $user_tz = new DateTimeZone($user_tz_string);
-                       } catch (Exception $e) {
-                               $user_tz = $utc_tz;
-                       }
+               $user_tz_string = get_pref('USER_TIMEZONE', $owner_uid);
 
-                       $tz_offset = $user_tz->getOffset($dt);
+               try {
+                       if (!$user_tz) $user_tz = new DateTimeZone($user_tz_string);
+               } catch (Exception $e) {
+                       $user_tz = $utc_tz;
                }
 
+               $tz_offset = $user_tz->getOffset($dt);
+
                $user_timestamp = $dt->format('U') + $tz_offset;
 
                if (!$no_smart_dt) {