@@ -285,13 +285,23 @@ public function testPrepareSummary($useAggregatedData, $mainTable, $isFilter, $g
285285 */
286286 public function testGetDateRangeFirstPart ($ range , $ customStart , $ customEnd , $ expectedInterval ): void
287287 {
288- $ timeZoneToReturn = date_default_timezone_get ();
289- date_default_timezone_set ('UTC ' );
290288 $ result = $ this ->collection ->getDateRange ($ range , $ customStart , $ customEnd );
291289 $ interval = $ result ['to ' ]->diff ($ result ['from ' ]);
292- date_default_timezone_set ($ timeZoneToReturn );
293290 $ intervalResult = $ interval ->format ('%y %m %d %h:%i:%s ' );
294- $ this ->assertEquals ($ expectedInterval , $ intervalResult );
291+ if ($ range === '7d ' && $ intervalResult !== $ expectedInterval ) {
292+ $ result ['from ' ]->setTimezone (new \DateTimeZone ('America/Chicago ' ));
293+ $ result ['to ' ]->setTimezone (new \DateTimeZone ('America/Chicago ' ));
294+ //Daylight saving check
295+ if (!date ('I ' , strtotime ($ result ['from ' ]->format ('Y-m-d H:i:s ' )))) {
296+ //when the start date does not fall during Daylight saving but the end date falls
297+ $ this ->assertEquals (strtotime ($ expectedInterval .' +1 hours ' ), strtotime ($ intervalResult ));
298+ } elseif (!date ('I ' , strtotime ($ result ['to ' ]->format ('Y-m-d H:i:s ' )))) {
299+ //when the end date does not fall during Daylight saving but the start date falls
300+ $ this ->assertEquals (strtotime ($ expectedInterval .' -1 hours ' ), strtotime ($ intervalResult ));
301+ }
302+ } else {
303+ $ this ->assertEquals ($ expectedInterval , $ intervalResult );
304+ }
295305 }
296306
297307 /**
0 commit comments