Skip to content

Commit

Permalink
Fix off-by-one error for all-day events in iCal generation
Browse files Browse the repository at this point in the history
  • Loading branch information
mschabhuettl committed Mar 3, 2024
1 parent c6fab81 commit bcd5d40
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .idea/SP5ToICalExp.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/utils/text_to_ical.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from datetime import datetime, timedelta
from dateutil import tz


def convert_shifts_to_ical(shifts, timezone='Europe/Vienna'):
"""
Converts a list of shift dictionaries into an iCal formatted calendar string.
Expand Down Expand Up @@ -29,7 +30,8 @@ def create_event(shift):

if shift.get("all_day", False):
e.name = shift["entry"]
e.begin = start_date.replace(tzinfo=tz_info)
start_date = datetime.strptime(shift["date"], "%a. %d.%m.%Y").date()
e.begin = start_date
e.make_all_day()
else:
start_time_str, end_time_str = shift["shift_time"].split("-")
Expand Down

0 comments on commit bcd5d40

Please sign in to comment.