on repeating single day events, the dtstart can no (longer?) be extracted -> handle like a single date event

This commit is contained in:
George Ruinelli 2024-03-20 22:14:16 +01:00
parent 77dd449d3e
commit 7385ada9b5

View File

@ -98,13 +98,13 @@ def fetch_calendar():
for eventraw in results: for eventraw in results:
eventUuid = str(eventraw).split("/")[-1].split(".")[0] eventUuid = str(eventraw).split("/")[-1].split(".")[0]
#print(" - %s" % eventUuid) #print(" - %s" % eventUuid)
#print(str(eventraw)) # print(str(eventraw))
#event = icalendar.Calendar.from_ical(eventraw._data) #event = icalendar.Calendar.from_ical(eventraw._data)
url = "https://" + cfg.userN + ":" + cfg.passW + "@" + str(eventraw).replace("Event: https://", "") url = "https://" + cfg.userN + ":" + cfg.passW + "@" + str(eventraw).replace("Event: https://", "")
#print(url) # print(url)
data = requests.get(url).text data = requests.get(url).text
event = icalendar.Calendar.from_ical(data) event = icalendar.Calendar.from_ical(data)
@ -114,23 +114,23 @@ def fetch_calendar():
##eventsList[day][eventUuid]["calendar"] = str(calendar).split("/")[-2] ##eventsList[day][eventUuid]["calendar"] = str(calendar).split("/")[-2]
eventsList[day][eventUuid]["calendar"] = str(calendar) eventsList[day][eventUuid]["calendar"] = str(calendar)
#print(" summary: %s" % component.get('summary')) # print(" summary: %s" % component.get('summary'))
eventsList[day][eventUuid]["summary"] = str(component.get('summary')) eventsList[day][eventUuid]["summary"] = str(component.get('summary'))
#print(" description: %s" % component.get('description')) # print(" description: %s" % component.get('description'))
#eventsList[day][eventUuid]["description"] = str(component.get('description')) #eventsList[day][eventUuid]["description"] = str(component.get('description'))
startDate = component.get('dtstart') startDate = component.get('dtstart')
#print(" dtstart: %s (%s)" % (startDate.dt.strftime('%m/%d/%Y %H:%M'), day)) # print(" dtstart: %s == %s?" % (startDate.dt.strftime('%m/%d/%Y %H:%M'), day))
if startDate.dt.strftime('%m/%d/%Y') == day.strftime('%m/%d/%Y'): # event starts today if startDate.dt.strftime('%m/%d/%Y') == day.strftime('%m/%d/%Y'): # event starts today
#print(" single day event") # print(" single day event")
eventsList[day][eventUuid]["startDate"] = startDate.dt.strftime('%m/%d/%Y') eventsList[day][eventUuid]["startDate"] = startDate.dt.strftime('%m/%d/%Y')
eventsList[day][eventUuid]["startTime"] = (startDate.dt + datetime.timedelta(hours=utcOffset)).strftime('%H:%M') eventsList[day][eventUuid]["startTime"] = (startDate.dt + datetime.timedelta(hours=utcOffset)).strftime('%H:%M')
else: # event started before today, set startdate to day and start time to midnight (for multi day events with start/end time) else: # event started before today, set startdate to day and start time to midnight (for multi day events with start/end time)
#print(" multi day event") # print(" multi day event")
eventsList[day][eventUuid]["startDate"] = day.strftime('%m/%d/%Y') eventsList[day][eventUuid]["startDate"] = day.strftime('%m/%d/%Y')
eventsList[day][eventUuid]["startTime"] = "00:00" # eventsList[day][eventUuid]["startTime"] = "00:00" # No longer working!
eventsList[day][eventUuid]["startTime"] = (startDate.dt + datetime.timedelta(hours=utcOffset)).strftime('%H:%M')
try: try:
endDate = component.get('dtend') endDate = component.get('dtend')
@ -140,7 +140,8 @@ def fetch_calendar():
eventsList[day][eventUuid]["endTime"] = (endDate.dt + datetime.timedelta(hours=utcOffset)).strftime('%H:%M') eventsList[day][eventUuid]["endTime"] = (endDate.dt + datetime.timedelta(hours=utcOffset)).strftime('%H:%M')
else: # event ends after today, set enddate to day and end time to midnight (for multi day events with start/end time) else: # event ends after today, set enddate to day and end time to midnight (for multi day events with start/end time)
eventsList[day][eventUuid]["endDate"] = day.strftime('%m/%d/%Y') eventsList[day][eventUuid]["endDate"] = day.strftime('%m/%d/%Y')
eventsList[day][eventUuid]["endTime"] = "24:00" # eventsList[day][eventUuid]["endTime"] = "24:00" # No longer working!
eventsList[day][eventUuid]["endDate"] = endDate.dt.strftime('%m/%d/%Y')
except AttributeError as ae: # event has no endtime, use duration except AttributeError as ae: # event has no endtime, use duration
#print(" %s" % ae) #print(" %s" % ae)