program fix previous events

This commit is contained in:
isUnknown 2024-11-04 15:32:13 +01:00
parent 94cf47ee43
commit 6875193964

View file

@ -54,34 +54,6 @@ function splitNextAndPreviousEvents($events) {
];
}
function filterPastEvents($events) {
$pastEvents = new Pages();
foreach ($events as $event) {
$sessions = $event->isMapadoEvent() == 'true' ? $event->remoteSessions()->toStructure() : $event->sessions()->toStructure();
$sessionDates = $sessions->map(function($session) {
return $session->date()->value();
})->data;
$pastDates = array_filter($sessionDates, function ($date) {
// strtotime() gives the timestamp for midnight
// time() gives the current timestamp so if the event occurs today it will be considered as past after midnight
// so we need to add a day, in seconds
$oneDayInSecond = 24*60*60;
$oneDayInSecond = 24*60*60;
$dateTimeStamp = strtotime($date) - $oneDayInSecond;
return $date < time();
});
if (count($pastDates) == count($sessionDates)) {
$pastEvents->add($event);
}
}
return $pastEvents;
}
function buildFieldsString($requestFields) {
$fields = [];
foreach ($requestFields as $field) {