Skip to content

Commit

Permalink
Correct timezone drift on non-rolling date caps.
Browse files Browse the repository at this point in the history
  • Loading branch information
heathdutton committed Jun 18, 2018
1 parent 1c14e2d commit b837641
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Entity/CacheRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ public function findLimit(
public function oldestDateAdded($duration, string $timezone = null, \DateTime $dateSend = null)
{
$oldest = $dateSend ? $dateSend : new \DateTime();
if (!$timezone) {
$timezone = date_default_timezone_get();
}
$oldest->setTimezone(new \DateTimeZone($timezone));
if (0 !== strpos($duration, 'P')) {
// Non-rolling interval, go to previous interval segment.
// Will only work for simple (singular) intervals.
if (!$timezone) {
$timezone = date_default_timezone_get();
}
$oldest->setTimezone(new \DateTimeZone($timezone));
switch (strtoupper(substr($duration, -1))) {
case 'Y':
$oldest->modify('next year jan 1 midnight');
Expand Down

0 comments on commit b837641

Please sign in to comment.