Skip to content

Commit

Permalink
Fix #687 - advance dates 1 day if next time is in next day
Browse files Browse the repository at this point in the history
  • Loading branch information
webian committed May 30, 2022
1 parent 714073b commit d4bcb16
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Classes/Service/TimeTable/TimeTimeTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,25 @@ protected function createNextLoopEntry(array $loopEntry, string $modification):
// Time modification
if (str_contains($modification, 'minutes') || str_contains($modification, 'hours')) {
$startTime = new \DateTime('@' . ($loopEntry['start_time'] ?? 0));
$compareTime = new \DateTime('@' . ($loopEntry['start_time'] ?? 0));
$startTime->modify($modification);
$loopEntry['start_time'] = $startTime->getTimestamp();

$endTime = new \DateTime('@' . ($loopEntry['end_time'] ?? 0));
$endTime->modify($modification);
$loopEntry['end_time'] = $endTime->getTimestamp();

if ($startTime->format('Y-m-d') !== $compareTime->format('Y-m-d')) {
/** @var $startDate \DateTime */
$startDate = clone $loopEntry['start_date'];
$startDate->modify('+1 day');
$loopEntry['start_date'] = $startDate;

/** @var $endDate \DateTime */
$endDate = clone $loopEntry['end_date'];
$endDate->modify('+1 day');
$loopEntry['end_date'] = $endDate;
}
} else {
/** @var $startDate \DateTime */
$startDate = clone $loopEntry['start_date'];
Expand Down

0 comments on commit d4bcb16

Please sign in to comment.