From f916e0ce2503d3be7050f8fd308e32451a98d49d Mon Sep 17 00:00:00 2001 From: Kevin Papst Date: Tue, 10 Nov 2020 16:02:30 +0100 Subject: [PATCH] fix timesheet importer for entries passing midnight (#2098) --- src/Command/ImportTimesheetCommand.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Command/ImportTimesheetCommand.php b/src/Command/ImportTimesheetCommand.php index 22f46f43..3883b020 100644 --- a/src/Command/ImportTimesheetCommand.php +++ b/src/Command/ImportTimesheetCommand.php @@ -345,6 +345,15 @@ class ImportTimesheetCommand extends Command } else { $begin = new \DateTime($record['Date'] . ' ' . $record['From'], $timezone); $end = new \DateTime($record['Date'] . ' ' . $record['To'], $timezone); + + // fix dates, which are running over midnight + if ($end < $begin) { + if ($duration > 0) { + $end = (new \DateTime())->setTimezone($timezone)->setTimestamp($begin->getTimestamp() + $duration); + } else { + $end->add(new \DateInterval('P1D')); + } + } } $timesheet = new Timesheet();