From 43ebff9c3287097d44422f2c01643ab62d4ecffa Mon Sep 17 00:00:00 2001 From: Daan Date: Tue, 26 Oct 2021 12:37:01 +0200 Subject: [PATCH] Hotfix : weekly timeframeutility had a daylight savings bug. --- composer.json | 2 +- index.php | 2 +- package.json | 2 +- src/models/SimpleStatsTimeFrameUtility.php | 6 ++++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 708ba49..a3a3834 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "daandelange/simplestats", "description": "Very minimal visitor analytics for your kirby3 website.", "type": "kirby-plugin", - "version": "0.4.2-beta", + "version": "0.4.3-beta", "license": "MIT", "authors": [ { diff --git a/index.php b/index.php index f0390a4..6bd178c 100755 --- a/index.php +++ b/index.php @@ -29,7 +29,7 @@ // optional replacement for the breadcrumb label 'breadcrumbLabel' => function () { - return 'SimppleStats - All your data are belong to us !'; + return 'SimpleStats - All your data are belong to us !'; }, // show / hide from the menu diff --git a/package.json b/package.json index 161a411..534ec4c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "SimpleStats", - "version": "0.4.2-beta", + "version": "0.4.3-beta", "description": "Simple analytics for your kirby website.", "main": "index.js", "author": "Daan de Lange", diff --git a/src/models/SimpleStatsTimeFrameUtility.php b/src/models/SimpleStatsTimeFrameUtility.php index a4ac52c..01de9c6 100644 --- a/src/models/SimpleStatsTimeFrameUtility.php +++ b/src/models/SimpleStatsTimeFrameUtility.php @@ -137,7 +137,7 @@ public function getTimeFromPeriod(int $period) : int { $year = substr(''.$period, 0,4); $week = substr(''.$period, 4,2); if($week && $year) return strtotime($year.'W'.$week)??0; - return 0; + return 0; // dangerous ! } public function getPeriodFromTime( int $time = -1 ) : int { @@ -147,7 +147,9 @@ public function getPeriodFromTime( int $time = -1 ) : int { public function incrementTime($time, $steps=1) : int { //$week = intval(date('W', $time),10)+$steps; //$year = intval( date('o', $time) + floor( ($week-1) / 53 ), 10); - return getTimeFromPeriod(getPeriodFromTime($time+(7*24*3600)*$steps)); + return strtotime(($steps<0?'-':'+').$steps.' week',$time); + //return getTimeFromPeriod(getPeriodFromTime($newTime+7*24*3600)); // In some rare cases (26-10-2021) this causes an infinite loop : // time = 1635112800 = 2021-43 while 1635112800+1week = 2021-43 . Note : end of week is dayligt saving + //return getTimeFromPeriod(getPeriodFromTime($time)+$steps)); } public function getPanelPeriodFormat() : string{ //return 'dd MMM yyyy'; // 26 Dec 2021