Try / catch invalid dates in NodaTimeSplitter

This commit is contained in:
Joshua Ramon Enslin 2022-02-03 21:12:54 +01:00
parent 09a5096588
commit d28618bb14
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -249,7 +249,13 @@ final class NodaTimeSplitter {
}
else if ($moda[0] === $moda[1] && trim((string)$moda[2], " 0") !== "" && trim((string)$moda[3], " 0") === "") {
setlocale(LC_TIME, NodaTimeAutotranslater::LANGS_TO_LOCALES['de']);
return $prefix . strftime(getMonthFormatByLang("de"), MD_STD::strtotime("{$moda[0]}-{$moda[2]}-01 01:01:01")) . $suffix;
try {
return $prefix . strftime(getMonthFormatByLang("de"), MD_STD::strtotime("{$moda[0]}-{$moda[2]}-01 01:01:01")) . $suffix;
}
catch (MDInvalidInputDate $e) {
return "";
}
}
return "";