]> git.wh0rd.org - tt-rss.git/commitdiff
add automatic timezone (based on client tz offset)
authorAndrew Dolgov <fox@fakecake.org>
Fri, 26 Apr 2013 06:31:57 +0000 (10:31 +0400)
committerAndrew Dolgov <fox@fakecake.org>
Fri, 26 Apr 2013 06:31:57 +0000 (10:31 +0400)
classes/rpc.php
include/functions.php
js/prefs.js
js/tt-rss.js
lib/timezones.txt

index 750aa2cb1399835ac4bc5a26ec307fd7c3ab45b7..62d884673473db5a59b8a1359265bfad5060e530 100644 (file)
@@ -334,6 +334,7 @@ class RPC extends Handler_Protected {
                $_SESSION["hasAudio"] = $_REQUEST["hasAudio"] === "true";
                $_SESSION["hasSandbox"] = $_REQUEST["hasSandbox"] === "true";
                $_SESSION["hasMp3"] = $_REQUEST["hasMp3"] === "true";
+               $_SESSION["clientTzOffset"] = $_REQUEST["clientTzOffset"];
 
                $reply = array();
 
index b54187e18b1c548b34ccc86523c29311d8c6f48d..4272c649d8a131f4a2b15d39e41febc870f653a9 100644 (file)
 
                $user_tz_string = get_pref('USER_TIMEZONE', $owner_uid);
 
-               try {
-                       if (!$user_tz) $user_tz = new DateTimeZone($user_tz_string);
-               } catch (Exception $e) {
-                       $user_tz = $utc_tz;
-               }
+               if ($user_tz_string != 'Automatic') {
 
-               $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);
+               } else {
+                       $tz_offset = (int) $_SESSION["clientTzOffset"];
+               }
 
                $user_timestamp = $dt->format('U') + $tz_offset;
 
index 8612b70fba2590640cebabe17d3f2f155c65890f..431a1fe84907040b30c2d0ce39beb63d2c6b3cd8 100644 (file)
@@ -962,8 +962,11 @@ function init() {
                dojo.addOnLoad(function() {
                        loading_set_progress(50);
 
+                       var clientTzOffset = new Date().getTimezoneOffset() * 60;
+
                        new Ajax.Request("backend.php", {
-                               parameters: {op: "rpc", method: "sanityCheck"},
+                               parameters: {op: "rpc", method: "sanityCheck",
+                                       clientTzOffset: clientTzOffset },
                                        onComplete: function(transport) {
                                        backend_sanity_check_callback(transport);
                                } });
index 88a360f9999742549d3f10fee50eb98faee05bd0..a7518959c577de99672ac1e8141b987d442ffdc1 100644 (file)
@@ -256,10 +256,12 @@ function init() {
                var hasAudio = !!a.canPlayType;
                var hasSandbox = "sandbox" in document.createElement("iframe");
                var hasMp3 = !!(a.canPlayType && a.canPlayType('audio/mpeg;').replace(/no/, ''));
+               var clientTzOffset = new Date().getTimezoneOffset() * 60;
 
                new Ajax.Request("backend.php", {
                        parameters: {op: "rpc", method: "sanityCheck", hasAudio: hasAudio,
                                hasMp3: hasMp3,
+                               clientTzOffset: clientTzOffset,
                                hasSandbox: hasSandbox},
                        onComplete: function(transport) {
                                        backend_sanity_check_callback(transport);
index 66824ec93f60d64414114c7f7432188de3c6a4eb..58108f031eccccd1968f66fe5a8fca8f34e98d4f 100644 (file)
@@ -1,3 +1,4 @@
+Automatic
 Africa/Abidjan
 Africa/Accra
 Africa/Addis_Ababa