Update ics_parser.py

Fixed date/datetime handling
Improved error logging
main
Keith Herrington 2024-12-11 12:16:17 -08:00 committed by GitHub
parent 3b3c59d49b
commit 1c399b1b1c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 3 deletions

View File

@ -17,7 +17,8 @@ class ICSParser:
end = event.get("DTEND").dt end = event.get("DTEND").dt
description = event.get("DESCRIPTION", "") description = event.get("DESCRIPTION", "")
if not description: if not description:
self.logger.debug(f"Skipping event with start date {start.date()} due to missing description") start_date = start if isinstance(start, datetime.date) else start.date()
self.logger.debug(f"Skipping event with start date {start_date} due to missing description")
continue continue
pin_code = "" pin_code = ""
for line in description.split("\n"): for line in description.split("\n"):
@ -25,8 +26,8 @@ class ICSParser:
pin_code = line.split(": ")[1].strip() pin_code = line.split(": ")[1].strip()
break break
reservations.append({ reservations.append({
"check_in_date": start.date() if isinstance(start, datetime.datetime) else start, "check_in_date": start if isinstance(start, datetime.date) else start.date(),
"check_out_date": end.date() if isinstance(end, datetime.datetime) else end, "check_out_date": end if isinstance(end, datetime.date) else end.date(),
"guests": [{"name": "Airbnb Guest", "phone": pin_code}], "guests": [{"name": "Airbnb Guest", "phone": pin_code}],
"status": "accepted" "status": "accepted"
}) })