From 29e70a4e372a56416a7ab835c6678c0c65320ba8 Mon Sep 17 00:00:00 2001 From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com> Date: Mon, 19 Aug 2024 13:07:57 +0200 Subject: [PATCH] Added support for format without comma --- application/controllers/Contestcalendar.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/application/controllers/Contestcalendar.php b/application/controllers/Contestcalendar.php index a3b58978b..7eebe29c9 100644 --- a/application/controllers/Contestcalendar.php +++ b/application/controllers/Contestcalendar.php @@ -72,7 +72,6 @@ class Contestcalendar extends CI_Controller { return $rssData; } - private function parseTimeRange($string) { $timeData = array(); @@ -86,7 +85,19 @@ class Contestcalendar extends CI_Controller { // create proper dateTime $timeData['start'] = DateTime::createFromFormat('Hi\Z, M d', $start); + + if (!$timeData['start']) { + // If the first format didn't match, try the format without the comma + $timeData['start'] = DateTime::createFromFormat('Hi\Z M d', $start); + } + $timeData['end'] = DateTime::createFromFormat('Hi\Z, M d', $end); + + if (!$timeData['end']) { + // If the first format didn't match, try the format without the comma + $timeData['end'] = DateTime::createFromFormat('Hi\Z M d', $end); + } + } else { // split in start and end time