Skip to content

Commit

Permalink
Parsing multiday events from ics files
Browse files Browse the repository at this point in the history
This is initial implementation of multiday events parsing to address issue #68. After this, still need to implement displaying the repeated events.
  • Loading branch information
anufrievroman committed Nov 23, 2023
1 parent 9ba93e4 commit 87ca8c5
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions calcure/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,8 @@ def parse_event(self, component, index, calendar_number):
"""Parse single event and add it to user_ics_events"""

# Default parameters:
hour = None
minute = None
event_id = index
repetition = '1'
frequency = Frequency.ONCE
Expand All @@ -409,7 +411,18 @@ def parse_event(self, component, index, calendar_number):
except AttributeError:
year, month, day = 0, 1, 1

# Add start time to the name of non-all-day events:
# See if this event takes multiple days:
try:
dt_end = component.get('dtend').dt
year_end, month_end, day_end = dt.year, dt.month, dt.day
dt_difference = dt_end - dt
if dt_difference.days > 0:
repetition = str(dt_difference.days + 1)
frequency = Frequency.DAILY
except AttributeError:
pass

# Add start time to non-all-day events:
if not all_day:
hour = dt.hour if dt else 0

Expand Down Expand Up @@ -440,9 +453,6 @@ def parse_event(self, component, index, calendar_number):
day = Calendar(0, self.use_persian_calendar).last_day(year, month)

minute = dt.minute if dt else 0
else:
hour = None
minute = None

# Convert to persian date if needed:
if self.use_persian_calendar:
Expand Down

0 comments on commit 87ca8c5

Please sign in to comment.