Skip to content

Commit

Permalink
Use UTC 00:00:00 when no exdate time specified
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanv committed Jun 8, 2023
1 parent c8324ad commit b4090e5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion tests/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,13 @@ def test_exception():
)
)
event_str = event.serialize()
# Handle line overflow
event_str = event_str.replace(" ", "").replace("\n", "").replace("\r", "")

# DTEND exists and is the next day, calendar tools import this
# correctly as being a one-day event
assert (
"EXDATE;TZID=/ics.py/2020.1/America/Los_Angeles:20220713,20220714T060000"
"EXDATE;TZID=/ics.py/2020.1/America/Los_Angeles:20220713T000000,20220714T060000"
in event_str
)
assert "RDATE;TZID=/ics.py/2020.1/America/Los_Angeles:20221224T060000" in event_str
Expand Down
4 changes: 3 additions & 1 deletion yaml2ics.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ def datetime2utc(date):
if isinstance(date, datetime.datetime):
return datetime.datetime.strftime(date, "%Y%m%dT%H%M%S")
elif isinstance(date, datetime.date):
return datetime.datetime.strftime(date, "%Y%m%d")
return datetime.datetime.strftime(date, "%Y%m%dT000000")
else:
raise RuntimeError(f"Unsure how to convert {date} to UTC")


# See RFC2445, 4.8.5 REcurrence Component Properties
Expand Down

0 comments on commit b4090e5

Please sign in to comment.