From 6ec188da237332f76a073bab77057680e5374781 Mon Sep 17 00:00:00 2001 From: Kevin Kofler Date: Fri, 16 Apr 2021 15:35:35 +0200 Subject: [PATCH] ICalService: Support start_time-end_time time specs E.g., "13:00-14:00". --- app/classes/Framadate/Services/ICalService.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/classes/Framadate/Services/ICalService.php b/app/classes/Framadate/Services/ICalService.php index 9d27abf..59bfa34 100644 --- a/app/classes/Framadate/Services/ICalService.php +++ b/app/classes/Framadate/Services/ICalService.php @@ -55,9 +55,22 @@ class ICalService { } $ical_text = ""; + $elements = explode("-", $start_time); + $end_time = null; + if(count($elements) === 2) { + $start_time = trim($elements[0]); + $end_time = trim($elements[1]); + } $start_time = $this->reviseTimeString($start_time); + if($end_time !== null) { + $end_time = $this->reviseTimeString($end_time); + } if($start_time !== null) { - $ical_text = $this->getTimedEvent1Hour($poll, $start_day . " " . $start_time); + if($end_time !== null) { + $ical_text = $this->getTimedEvent($poll, $start_day . " " . $start_time, $start_day . " " . $end_time); + } else { + $ical_text = $this->getTimedEvent1Hour($poll, $start_day . " " . $start_time); + } } else { $date = DateTime::createFromFormat('d-m-Y', $start_day);