improve error management
This commit is contained in:
parent
a23a5ba06b
commit
2f0a8f36d8
2 changed files with 14 additions and 5 deletions
|
|
@ -174,10 +174,19 @@ function saveMapadoEvent($mapadoEvent, $page) {
|
||||||
|
|
||||||
function getEndTime($session) {
|
function getEndTime($session) {
|
||||||
$formattedTime = strlen($session['time']) < 4 ? $session['time'] . '00' : $session['time'];
|
$formattedTime = strlen($session['time']) < 4 ? $session['time'] . '00' : $session['time'];
|
||||||
$time1 = DateTime::createFromFormat('G\hi', $formattedTime);
|
$time1 = DateTime::createFromFormat('Hi', $formattedTime);
|
||||||
|
if ($time1 === false) {
|
||||||
|
throw new Exception('format d\'heure invalide : ' . $session['time']);
|
||||||
|
}
|
||||||
|
|
||||||
$formattedDuration = strlen($session['duration']) < 4 ? $session['duration'] . '00' : $session['duration'];
|
$formattedDuration = strlen($session['duration']) < 4 ? $session['duration'] . '00' : $session['duration'];
|
||||||
$time2 = DateTime::createFromFormat('G\hi', $formattedDuration);
|
$time2 = DateTime::createFromFormat('Hi', $formattedDuration);
|
||||||
|
if ($time2 === false) {
|
||||||
|
throw new Exception('format de durée invalide : ' . $session['duration']);
|
||||||
|
}
|
||||||
|
|
||||||
$time1->add(new DateInterval('PT' . $time2->format('H') . 'H' . $time2->format('i') . 'M'));
|
$time1->add(new DateInterval('PT' . $time2->format('H') . 'H' . $time2->format('i') . 'M'));
|
||||||
$endTime = $time1->format('G\hi');
|
|
||||||
return $endTime;
|
return $time1->format('H:i');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@
|
||||||
try {
|
try {
|
||||||
$endTime = strlen($session['duration']) > 0 ? getEndTime($session) : false;
|
$endTime = strlen($session['duration']) > 0 ? getEndTime($session) : false;
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
throw new Exception($session['title'], 1);
|
throw new Exception($session['title'] .' - ' . $th->getMessage(), 1);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<template x-if="tab === 'Calendrier' || ('<?= $session['categories'] ?>'.length > 0 && tab.includes('<?= $session['categories'] ?>'))">
|
<template x-if="tab === 'Calendrier' || ('<?= $session['categories'] ?>'.length > 0 && tab.includes('<?= $session['categories'] ?>'))">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue