summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-04-26 10:31:57 +0400
committerAndrew Dolgov <[email protected]>2013-04-26 10:31:57 +0400
commit6bfc97da869ca180d2f5fee01c9ff503cb47b1bd (patch)
treec495b5ac3d3701399cf657615de8c5f221d6f74e
parent5ddef5ba238ad8bdfc23344b3bb3297067eb1747 (diff)
add automatic timezone (based on client tz offset)
-rw-r--r--classes/rpc.php1
-rw-r--r--include/functions.php17
-rw-r--r--js/prefs.js5
-rw-r--r--js/tt-rss.js2
-rw-r--r--lib/timezones.txt1
5 files changed, 19 insertions, 7 deletions
diff --git a/classes/rpc.php b/classes/rpc.php
index 750aa2cb1..62d884673 100644
--- a/classes/rpc.php
+++ b/classes/rpc.php
@@ -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();
diff --git a/include/functions.php b/include/functions.php
index b54187e18..4272c649d 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -862,13 +862,18 @@
$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;
diff --git a/js/prefs.js b/js/prefs.js
index 8612b70fb..431a1fe84 100644
--- a/js/prefs.js
+++ b/js/prefs.js
@@ -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);
} });
diff --git a/js/tt-rss.js b/js/tt-rss.js
index 88a360f99..a7518959c 100644
--- a/js/tt-rss.js
+++ b/js/tt-rss.js
@@ -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);
diff --git a/lib/timezones.txt b/lib/timezones.txt
index 66824ec93..58108f031 100644
--- a/lib/timezones.txt
+++ b/lib/timezones.txt
@@ -1,3 +1,4 @@
+Automatic
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa