VCL-1109 - date duplicated on statistic graph labels for day after daylight saving time rolls back
The fix mentioned in VCL-1109 of just adding a value to the label doesn't really fix the underlying problem and give incorrect values on the graphs. A better fix was to change the timezone to UTC before doing any date work so that DST isn't used.
statistics.php: modified getStatGraphDayData, getStatGraphDayConUsersData, getStatGraphConBladeUserData, and getStatGraphConVMUserData: added a call at the beginning of each function to get the current timezone, then set the timezone to UTC; added a call before any returns in each function that sets the timezone back to was was retreived at the beginning of the function
diff --git a/web/.ht-inc/statistics.php b/web/.ht-inc/statistics.php
index 4127fe1..cd85fda 100644
--- a/web/.ht-inc/statistics.php
+++ b/web/.ht-inc/statistics.php
@@ -665,6 +665,8 @@
///
////////////////////////////////////////////////////////////////////////////////
function getStatGraphDayData($start, $end, $affilid, $mode, $provid) {
+ $tz = date_default_timezone_get();
+ date_default_timezone_set('UTC');
$startunix = datetimeToUnix($start . " 00:00:00");
$endunix = datetimeToUnix($end . " 23:59:59");
@@ -749,6 +751,7 @@
}
if(count($addcache))
addToStatGraphCache('totalres', $addcache, $affilid, $provid);
+ date_default_timezone_set($tz);
return($data);
}
@@ -920,6 +923,8 @@
///
////////////////////////////////////////////////////////////////////////////////
function getStatGraphDayConUsersData($start, $end, $affilid, $mode, $provid) {
+ $tz = date_default_timezone_get();
+ date_default_timezone_set('UTC');
$startdt = $start . " 00:00:00";
$enddt = $end . " 23:59:59";
$startunix = datetimeToUnix($startdt);
@@ -955,6 +960,7 @@
$cachepts[$row['statdate']] = $row['value'];
if((count($cachepts) + 31) < $daycnt) {
$data = array('nodata' => i('(too much computational time required to generate this graph)'));
+ date_default_timezone_set($tz);
return $data;
}
for($daystart = $startunix; $daystart < $endunix; $daystart += SECINDAY) {
@@ -1038,6 +1044,7 @@
}
if(count($addcache))
addToStatGraphCache('concurres', $addcache, $affilid, $provid);
+ date_default_timezone_set($tz);
return($data);
}
@@ -1064,6 +1071,8 @@
///
////////////////////////////////////////////////////////////////////////////////
function getStatGraphConBladeUserData($start, $end, $affilid, $mode, $provid) {
+ $tz = date_default_timezone_get();
+ date_default_timezone_set('UTC');
$startdt = $start . " 00:00:00";
$enddt = $end . " 23:59:59";
$startunix = datetimeToUnix($startdt);
@@ -1099,6 +1108,7 @@
$cachepts[$row['statdate']] = $row['value'];
if((count($cachepts) + 31) < $daycnt) {
$data = array('nodata' => i('(too much computational time required to generate this graph)'));
+ date_default_timezone_set($tz);
return $data;
}
for($daystart = $startunix; $daystart < $endunix; $daystart += SECINDAY) {
@@ -1216,6 +1226,7 @@
}
if(count($addcache))
addToStatGraphCache('concurblade', $addcache, $affilid, $provid);
+ date_default_timezone_set($tz);
return($data);
}
@@ -1242,6 +1253,8 @@
///
////////////////////////////////////////////////////////////////////////////////
function getStatGraphConVMUserData($start, $end, $affilid, $mode, $provid) {
+ $tz = date_default_timezone_get();
+ date_default_timezone_set('UTC');
$startdt = $start . " 00:00:00";
$enddt = $end . " 23:59:59";
$startunix = datetimeToUnix($startdt);
@@ -1277,6 +1290,7 @@
$cachepts[$row['statdate']] = $row['value'];
if((count($cachepts) + 31) < $daycnt) {
$data = array('nodata' => i('(too much computational time required to generate this graph)'));
+ date_default_timezone_set($tz);
return $data;
}
for($daystart = $startunix; $daystart < $endunix; $daystart += SECINDAY) {
@@ -1378,6 +1392,7 @@
}
if(count($addcache))
addToStatGraphCache('concurvm', $addcache, $affilid, $provid);
+ date_default_timezone_set($tz);
return($data);
}