This commit is contained in:
isUnknown 2024-09-10 13:47:04 +02:00
parent 2f0a8f36d8
commit e58e630f9b
5 changed files with 27 additions and 31 deletions

View file

@ -146,10 +146,6 @@ function saveMapadoEvent($mapadoEvent, $page) {
$eventDateId = $eventDateId[count($eventDateId) - 1];
$ticketingUrl = option('ticketingUrl') . 'event/' . $mapadoEvent->slug . '?eventDate=' . $eventDateId;
if (isset($session->endDate) && !$duration) {
$endTime = substr($session->endDate, 11 , 5);
$duration = getTimeDifference($startTime, $endTime);
}
$sessionsToSave[] = [
"date" => substr($session->startDate, 0, 10),
@ -161,7 +157,6 @@ function saveMapadoEvent($mapadoEvent, $page) {
$dataToSave = [
"mapadoSlug" => $mapadoEvent->slug,
"remoteDuration" => $duration,
"remoteSessions" => $sessionsToSave,
"eventDateId" => $eventDateId,
"totalStock" => $totalStock
@ -173,18 +168,22 @@ function saveMapadoEvent($mapadoEvent, $page) {
}
function getEndTime($session) {
$formattedTime = strlen($session['time']) < 4 ? $session['time'] . '00' : $session['time'];
$formattedTime = preg_replace('/[^0-9]/', '', $session['time']);
$formattedTime = strlen($formattedTime) < 4 ? str_pad($formattedTime, 4, '0', STR_PAD_RIGHT) : $formattedTime;
$time1 = DateTime::createFromFormat('Hi', $formattedTime);
if ($time1 === false) {
throw new Exception('format d\'heure invalide : ' . $session['time']);
throw new Exception('format d\'heure invalide : ' . $session['time']);
}
$formattedDuration = strlen($session['duration']) < 4 ? $session['duration'] . '00' : $session['duration'];
$formattedDuration = preg_replace('/[^0-9]/', '', $session['duration']);
$formattedDuration = strlen($formattedDuration) < 4 ? str_pad($formattedDuration, 4, '0', STR_PAD_RIGHT) : $formattedDuration;
$time2 = DateTime::createFromFormat('Hi', $formattedDuration);
if ($time2 === false) {
throw new Exception('format de durée invalide : ' . $session['duration']);
throw new Exception('format de durée invalide : ' . $session['duration']);
}
$time1->add(new DateInterval('PT' . $time2->format('H') . 'H' . $time2->format('i') . 'M'));
return $time1->format('H:i');