From 5be965b5315ca1dbe4a2559e2694faeb379c5959 Mon Sep 17 00:00:00 2001 From: gregmeszaros Date: Fri, 5 Oct 2018 17:10:59 +0100 Subject: [PATCH 1/4] set local time --- web/minerHelper.php | 9 ++++++ web/templates/footer.html | 60 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 66 insertions(+), 3 deletions(-) diff --git a/web/minerHelper.php b/web/minerHelper.php index d0e7230..c65cbcb 100644 --- a/web/minerHelper.php +++ b/web/minerHelper.php @@ -587,6 +587,15 @@ public static function getClientIp() { */ public static function checkWallet($coin_seo_name = FALSE) { + // Check for the time_zone cookie, if set then reset the default timezone + if (!empty($_COOKIE['userLocalTimeZone'])) { + $time_zone = json_decode($_COOKIE['userLocalTimeZone'], true); + // Make sure there's an available abbreviation before setting the timezone + if (timezone_name_from_abbr( '', $time_zone['offset'] +60, $time_zone['dst'])) { + date_default_timezone_set( timezone_name_from_abbr('', $time_zone['offset'] +60, $time_zone['dst'])); + } + } + // First check if we have something in get if (!empty($_GET['wallet'])) { // Update cookie diff --git a/web/templates/footer.html b/web/templates/footer.html index 1dc2db4..e65fd10 100644 --- a/web/templates/footer.html +++ b/web/templates/footer.html @@ -24,9 +24,63 @@
Fork based on YiiMP project
{% if load_charts %} From ca6898322e8d0b46e934dbaa290f63195809475e Mon Sep 17 00:00:00 2001 From: gregmeszaros Date: Fri, 5 Oct 2018 17:32:44 +0100 Subject: [PATCH 2/4] fix --- web/minerHelper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/minerHelper.php b/web/minerHelper.php index c65cbcb..93b3901 100644 --- a/web/minerHelper.php +++ b/web/minerHelper.php @@ -591,8 +591,8 @@ public static function checkWallet($coin_seo_name = FALSE) { if (!empty($_COOKIE['userLocalTimeZone'])) { $time_zone = json_decode($_COOKIE['userLocalTimeZone'], true); // Make sure there's an available abbreviation before setting the timezone - if (timezone_name_from_abbr( '', $time_zone['offset'] +60, $time_zone['dst'])) { - date_default_timezone_set( timezone_name_from_abbr('', $time_zone['offset'] +60, $time_zone['dst'])); + if (timezone_name_from_abbr( '', ($time_zone['offset'] + 60) * 60, $time_zone['dst'])) { + date_default_timezone_set( timezone_name_from_abbr('', ($time_zone['offset'] + 60) * 60, $time_zone['dst'])); } } From 6b23102245c4ebd8ce023186e3fc803208403d5b Mon Sep 17 00:00:00 2001 From: gregmeszaros Date: Fri, 5 Oct 2018 17:52:10 +0100 Subject: [PATCH 3/4] time zone offset --- web/minerHelper.php | 5 +++++ web/templates/blocks.html.twig | 1 + 2 files changed, 6 insertions(+) diff --git a/web/minerHelper.php b/web/minerHelper.php index 93b3901..288afb1 100644 --- a/web/minerHelper.php +++ b/web/minerHelper.php @@ -991,6 +991,10 @@ public static function _templateVariables($db = FALSE, $route = null, $data = FA case 'blocks': $blocks = minerHelper::getBlocks($db, $data['coin_id']); + if (!empty($_COOKIE['userLocalTimeZone'])) { + $time_zone = json_decode($_COOKIE['userLocalTimeZone'], true); + } + // Load last 30 blocks return [ 'blocks' => $blocks, @@ -999,6 +1003,7 @@ public static function _templateVariables($db = FALSE, $route = null, $data = FA 'hashrate_user_24_hours' => $hashrate_user_24_hours ?? FALSE, 'coin_seo_name' => $data['coin_seo_name'], 'seo_site_name' => $data['seo_site_name'], + 'offset' => $time_zone['offset'], 'load_blocks_charts' => TRUE ]; break; diff --git a/web/templates/blocks.html.twig b/web/templates/blocks.html.twig index ee652a8..78b7cce 100644 --- a/web/templates/blocks.html.twig +++ b/web/templates/blocks.html.twig @@ -30,6 +30,7 @@ {% endfor %} +

Offset from GMT: {{ offset }} minutes -> times are adjusted to your local timezone!

From 024830841176cd2377fd0e4383896e9809856e17 Mon Sep 17 00:00:00 2001 From: gregmeszaros Date: Fri, 5 Oct 2018 18:08:01 +0100 Subject: [PATCH 4/4] local time --- web/minerHelper.php | 5 +++-- web/templates/footer.html | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/web/minerHelper.php b/web/minerHelper.php index 288afb1..5e6c962 100644 --- a/web/minerHelper.php +++ b/web/minerHelper.php @@ -591,8 +591,9 @@ public static function checkWallet($coin_seo_name = FALSE) { if (!empty($_COOKIE['userLocalTimeZone'])) { $time_zone = json_decode($_COOKIE['userLocalTimeZone'], true); // Make sure there's an available abbreviation before setting the timezone - if (timezone_name_from_abbr( '', ($time_zone['offset'] + 60) * 60, $time_zone['dst'])) { - date_default_timezone_set( timezone_name_from_abbr('', ($time_zone['offset'] + 60) * 60, $time_zone['dst'])); + + if (timezone_name_from_abbr( '', ($time_zone['offset'] - 60) * 60, $time_zone['dst'])) { + date_default_timezone_set( timezone_name_from_abbr('', ($time_zone['offset'] - 60) * 60, $time_zone['dst'])); } } diff --git a/web/templates/footer.html b/web/templates/footer.html index e65fd10..c6d2b45 100644 --- a/web/templates/footer.html +++ b/web/templates/footer.html @@ -30,7 +30,7 @@ function setTimeOffset() { // Create all the dates necessary var now = later = d1 = d2 = new Date(), - set = { 'offset': now.getTimezoneOffset(), 'dst': 0 } + set = { 'offset': now.getTimezoneOffset() * -1, 'dst': 0 } // Set time for how long the cookie should be saved - 1 year later.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000); // Date one is set to January 1st of this year