fix timesheet importer for entries passing midnight (#2098)

This commit is contained in:
Kevin Papst
2020-11-10 16:02:30 +01:00
committed by GitHub
parent bd4efad22b
commit f916e0ce25

View File

@@ -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();