From a8aaece1807ec3a29cb844ab1f4a7cf9685aa4a3 Mon Sep 17 00:00:00 2001 From: Jean-Marie Favreau Date: Wed, 1 May 2024 16:18:53 +0200 Subject: [PATCH] =?UTF-8?q?Correction=20de=20la=20dur=C3=A9e=20d'=C3=A9v?= =?UTF-8?q?=C3=A9nements=20durant=20plus=20d'un=20jour?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/agenda_culturel/import_tasks/extractor_ical.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/agenda_culturel/import_tasks/extractor_ical.py b/src/agenda_culturel/import_tasks/extractor_ical.py index 9d4d3d9..7b184d7 100644 --- a/src/agenda_culturel/import_tasks/extractor_ical.py +++ b/src/agenda_culturel/import_tasks/extractor_ical.py @@ -4,7 +4,7 @@ import warnings from icalendar import vDatetime import bbcode -from datetime import datetime, date +from datetime import datetime, date, timedelta from bs4 import BeautifulSoup, MarkupResemblesLocatorWarning from .extractor import * @@ -67,6 +67,12 @@ class ICALExtractor(Extractor): start_day, start_time = self.get_dt_item_from_vevent(event, "DTSTART") end_day, end_time = self.get_dt_item_from_vevent(event, "DTEND") + + # if the start and end are only defined by dates (and not times), + # then the event does not occurs on the last day (because it is the end + # of the event...) + if not start_time and not end_time and start_day != end_day: + end_day = end_day + timedelta(days=-1) location = self.get_item_from_vevent(event, "LOCATION") if location is None: