Skip to content

Commit

Permalink
Hotfix : weekly timeframeutility had a daylight savings bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daandelange committed Oct 26, 2021
1 parent 3741e9a commit 43ebff9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
6 changes: 4 additions & 2 deletions src/models/SimpleStatsTimeFrameUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit 43ebff9

Please sign in to comment.