Correction de la durée d'événements durant plus d'un jour

This commit is contained in:
Jean-Marie Favreau 2024-05-01 16:18:53 +02:00
parent f226d3cac6
commit a8aaece180

View File

@ -4,7 +4,7 @@ import warnings
from icalendar import vDatetime from icalendar import vDatetime
import bbcode import bbcode
from datetime import datetime, date from datetime import datetime, date, timedelta
from bs4 import BeautifulSoup, MarkupResemblesLocatorWarning from bs4 import BeautifulSoup, MarkupResemblesLocatorWarning
from .extractor import * from .extractor import *
@ -68,6 +68,12 @@ class ICALExtractor(Extractor):
end_day, end_time = self.get_dt_item_from_vevent(event, "DTEND") 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") location = self.get_item_from_vevent(event, "LOCATION")
if location is None: if location is None:
location = self.default_value_if_exists(default_values, "location") location = self.default_value_if_exists(default_values, "location")