From e6c97a64994e727ef96a079e6e690a5f1057e1fb Mon Sep 17 00:00:00 2001 From: katamaz Date: Sat, 10 Jan 2026 18:28:58 +0300 Subject: [PATCH] dx v2: fix no day match --- backend-php/api.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/backend-php/api.php b/backend-php/api.php index 621a144..7575dee 100644 --- a/backend-php/api.php +++ b/backend-php/api.php @@ -13,26 +13,26 @@ function findClosestDateSort($array, $targetDate) if (empty($array) || !preg_match('/^\d{1,2}-\d{1,2}-\d{2}$/', $targetDate)) { return null; } - + $targetDateTime = DateTime::createFromFormat('d-m-y', $targetDate); if ($targetDateTime === false) return null; $targetTimestamp = $targetDateTime->getTimestamp(); - + $result = null; $maxTimestamp = null; - + foreach ($array as $item) { $itemDateTime = DateTime::createFromFormat('d-m-y', $item['fromDate']); if ($itemDateTime === false) continue; - + $itemTimestamp = $itemDateTime->getTimestamp(); if ($itemTimestamp <= $targetTimestamp && ($maxTimestamp === null || $itemTimestamp > $maxTimestamp)) { $maxTimestamp = $itemTimestamp; $result = $item; } } - - return $result; + + return $result ?: ['content' => '[]']; } function getDayOfWeek(string $date) {