Calender: Always add end date (Z#23131739) (#3622)

This commit is contained in:
Richard Schreiber
2023-09-28 16:05:03 +02:00
committed by GitHub
parent 78fbfc9c80
commit c6cf8b6f24
2 changed files with 17 additions and 9 deletions

View File

@@ -68,13 +68,18 @@ def get_public_ical(events):
else:
vevent.add('dtstart').value = ev.date_from.astimezone(tz).date()
if event.settings.show_date_to and ev.date_to:
if event.settings.show_times:
vevent.add('dtend').value = ev.date_to.astimezone(tz)
else:
# with full-day events date_to in pretix is included (e.g. last day)
# whereas dtend in vcalendar is non-inclusive => add one day for export
vevent.add('dtend').value = ev.date_to.astimezone(tz).date() + datetime.timedelta(days=1)
# always add dtend as calendar apps otherwise have display issues
use_date_to = event.settings.show_date_to and ev.date_to
dtend = (ev.date_to if use_date_to else ev.date_from).astimezone(tz)
if not event.settings.show_times:
# with full-day events date_to in pretix is included (e.g. last day)
# whereas dtend in vcalendar is non-inclusive => add one day for export
dtend = dtend.date() + datetime.timedelta(days=1)
elif not use_date_to:
# date_from used as end-date => add 1h as a default duration
dtend = dtend + datetime.timedelta(hours=1)
vevent.add('dtend').value = dtend
descr = []
descr.append(_('Tickets: {url}').format(url=url))