Skip to content

Commit

Permalink
fix Interpretation/Time calculated 'dateend' when using 'year' and 'm…
Browse files Browse the repository at this point in the history
…onth' filter options - dateend must be date only, without time, therefor 00:00 of date is ingored and whole day got's included in result, resulting in first day of next cycle was inlcuded
  • Loading branch information
CybotTM committed Apr 5, 2019
1 parent dcba619 commit 7636b95
Showing 1 changed file with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -374,17 +374,29 @@ private function getEntries(Request $request, $maxResults = null)
if (null !== $year) {
$month = $this->evalParam($request, 'month');
if (null !== $month) {
$datestart = $year . '-' . $month . '-01T00:00:00';
$dateend = \DateTime::createFromFormat('Y-m-d\TH:i:s', $datestart);
// first day of month
$datestart = $year . '-' . $month . '-01';

// last day of month
$dateend = \DateTime::createFromFormat('Y-m-d', $datestart);
$dateend->add(new \DateInterval('P1M'));
// go back 1 day, to set date from first day of next month back to last day of last month
// e.g. 2019-05-01 -> 2019-04-30
$dateend->sub(new \DateInterval('P1D'));
} else {
$datestart = $year . '-01-01T00:00:00';
$dateend = \DateTime::createFromFormat('Y-m-d\TH:i:s', $datestart);
// first day of year
$datestart = $year . '-01-01';

// last day of year
$dateend = \DateTime::createFromFormat('Y-m-d', $datestart);
$dateend->add(new \DateInterval('P1Y'));
// go back 1 day, to set date from first day of next year back to last day of last year
// e.g. 2019-01-01 -> 2018-12-31
$dateend->sub(new \DateInterval('P1D'));
}

$arParams['datestart'] = $datestart;
$arParams['dateend'] = $dateend->format('Y-m-d\TH:i:s');
$arParams['dateend'] = $dateend->format('Y-m-d');
}

if (!$arParams['customer']
Expand Down

0 comments on commit 7636b95

Please sign in to comment.