Skip to content

Commit

Permalink
REV-18227 - DEVONLY - Fix bug in analytics-bundle to allow custom dat… (
Browse files Browse the repository at this point in the history
#10)

* REV-18227 - DEVONLY - Fix bug in analytics-bundle to allow custom date ranges

* REV-18227 - DEVONLY - Fix bug in analytics-bundle to allow custom date ranges

* REV-18227 - DEVONLY - Fix bug in analytics-bundle to allow custom date ranges

* REV-18227 - DEVONLY - Fix bug in analytics-bundle to allow custom date ranges
  • Loading branch information
revinatemarcos authored Jul 3, 2019
1 parent 208584e commit 54156b9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
9 changes: 5 additions & 4 deletions Lib/DateHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,11 @@ public static function getPeriodInfo($periodName, $time = null, $timezone = 'UTC
$return = array('period' => $period, 'description' => 'Quarter To Date: ' . date('n/j/y', strtotime($period[0])) . '-' . date('n/j/y'), 'short_description' => 'Quarter To Date');
} elseif (strpos($periodName, '-') !== false) {
$pieces = explode("-", $periodName);
$period[0] = ($pieces[0]);
$period[1] = ($pieces[1]);
$period[0] = date('Y-m-d', strtotime($pieces[0]));
$period[1] = 'custom';
$period[2] = date('Y-m-d', strtotime($pieces[1]));
$return = array('period' => $period, "description" => "Custom Date Range " . date('m/d/y', strtotime($period[0]))
. " - " . date('m/d/y', strtotime($period[1])), 'short_description' => 'Custom Date Range');
. " - " . date('m/d/y', strtotime($period[2])), 'short_description' => 'Custom Date Range');
} elseif (preg_match('/l([\d]+)d/', $periodName, $matches)) {
$howLong = $matches[1] - 1;
$days = $matches[1];
Expand Down Expand Up @@ -534,4 +535,4 @@ public static function getIntervalTimestampsForES($period, $scale) {
}
return $timestamps;
}
}
}
11 changes: 10 additions & 1 deletion Test/TestCase/Helper/DateHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,14 @@ public function testGetPeriodInfo() {
);

$this->assertEquals($ytdpyExpectedResults, DateHelper::getPeriodInfo('ytdpy', strtotime('December 15 2015')));

// Custom Date Range
$customExpectedResults = array(
'period' => array('2014-01-01', 'custom', '2014-12-15'),
'description' => 'Custom Date Range 01/01/14 - 12/15/14',
'short_description' => 'Custom Date Range'
);

$this->assertEquals($customExpectedResults, DateHelper::getPeriodInfo('01/01/2014-12/15/2014'));
}
}
}

0 comments on commit 54156b9

Please sign in to comment.