Skip to content

Commit dfacb6c

Browse files
authored
ENGCOM-5113: fix date calculation for report's years interval #22868
2 parents 211dd25 + 36bd8ff commit dfacb6c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

app/code/Magento/Reports/Model/ResourceModel/Report/Collection.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
namespace Magento\Reports\Model\ResourceModel\Report;
1313

1414
/**
15+
* Class Collection
16+
*
1517
* @api
1618
* @since 100.0.2
1719
*/
@@ -100,6 +102,7 @@ public function __construct(
100102

101103
/**
102104
* Set period
105+
*
103106
* @codeCoverageIgnore
104107
*
105108
* @param int $period
@@ -113,6 +116,7 @@ public function setPeriod($period)
113116

114117
/**
115118
* Set interval
119+
*
116120
* @codeCoverageIgnore
117121
*
118122
* @param \DateTimeInterface $fromDate
@@ -248,7 +252,7 @@ protected function _getYearInterval(\DateTime $dateStart, \DateTime $dateEnd, $f
248252
? $this->_localeDate->convertConfigTimeToUtc($dateStart->format('Y-m-d 00:00:00'))
249253
: $this->_localeDate->convertConfigTimeToUtc($dateStart->format('Y-01-01 00:00:00'));
250254

251-
$interval['end'] = $dateStart->diff($dateEnd)->y == 0
255+
$interval['end'] = $dateStart->format('Y') === $dateEnd->format('Y')
252256
? $this->_localeDate->convertConfigTimeToUtc(
253257
$dateStart->setDate($dateStart->format('Y'), $dateEnd->format('m'), $dateEnd->format('d'))
254258
->format('Y-m-d 23:59:59')
@@ -275,6 +279,7 @@ public function getPeriods()
275279

276280
/**
277281
* Set store ids
282+
*
278283
* @codeCoverageIgnore
279284
*
280285
* @param array $storeIds
@@ -288,6 +293,7 @@ public function setStoreIds($storeIds)
288293

289294
/**
290295
* Get store ids
296+
*
291297
* @codeCoverageIgnore
292298
*
293299
* @return array
@@ -309,6 +315,7 @@ public function getSize()
309315

310316
/**
311317
* Set page size
318+
*
312319
* @codeCoverageIgnore
313320
*
314321
* @param int $size
@@ -322,6 +329,7 @@ public function setPageSize($size)
322329

323330
/**
324331
* Get page size
332+
*
325333
* @codeCoverageIgnore
326334
*
327335
* @return int

0 commit comments

Comments
 (0)