Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions yaml2ics.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
}


def datetime2utc(date):
def datetime_to_str(date):
if isinstance(date, datetime.datetime):
return datetime.datetime.strftime(date, "%Y%m%dT%H%M%S")
return datetime.datetime.strftime(date, "%Y%m%dT%H%M%S%z")
elif isinstance(date, datetime.date):
return datetime.datetime.strftime(date, "%Y%m%d")
return datetime.datetime.strftime(date, "%Y%m%d%z")


def utcnow():
Expand Down Expand Up @@ -122,11 +122,11 @@ def event_from_yaml(event_yaml: dict, tz: datetime.tzinfo = None) -> ics.Event:
)

if "except_on" in repeat:
exdates = [datetime2utc(rdate) for rdate in repeat["except_on"]]
exdates = [datetime_to_str(rdate) for rdate in repeat["except_on"]]
add_recurrence_property(event, "EXDATE", exdates, tz)

if "also_on" in repeat:
rdates = [datetime2utc(rdate) for rdate in repeat["also_on"]]
rdates = [datetime_to_str(rdate) for rdate in repeat["also_on"]]
add_recurrence_property(event, "RDATE", rdates, tz)

event.dtstamp = utcnow()
Expand Down
Loading