Add exception catching in splitting times / dates

This commit is contained in:
Joshua Ramon Enslin 2021-01-06 23:11:05 +01:00
parent 54764e741a
commit c02165df7b
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -1004,8 +1004,13 @@ final class NodaTimeSplitter {
if ($start[4] === '-') return []; if ($start[4] === '-') return [];
try {
$startDate = new DateTime($start[4] . $start[0] . '-' . $start[2] . '-' . $start[3]); $startDate = new DateTime($start[4] . $start[0] . '-' . $start[2] . '-' . $start[3]);
$endDate = new DateTime($end[4] . $end[1] . '-' . $end[2] . '-' . $end[3]); $endDate = new DateTime($end[4] . $end[1] . '-' . $end[2] . '-' . $end[3]);
}
catch (Exception $e) {
return [];
}
$interval = $startDate->diff($endDate); $interval = $startDate->diff($endDate);
$days_diff = (int)$interval->format('%a'); $days_diff = (int)$interval->format('%a');