WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Open
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
11 changes: 8 additions & 3 deletions icalevents/icalparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ def parse_events(
tzinfo=None,
sort=False,
strict=False,
include_component=False,
):
"""
Query the events occurring in a given time range.
Expand Down Expand Up @@ -323,14 +324,16 @@ def parse_events(

found = []

def add_if_not_exception(event):
def add_if_not_exception(event, component):
exdate = "%04d%02d%02d" % (
event.start.year,
event.start.month,
event.start.day,
)

if exdate not in exceptions:
if component:
event.component = component
found.append(event)

for component in calendar.walk():
Expand Down Expand Up @@ -379,10 +382,12 @@ def add_if_not_exception(event):
)
else:
ecopy = e.copy_to(dt.date() if type(s) is date else dt, e.uid)
add_if_not_exception(ecopy)
add_if_not_exception(
ecopy, component if include_component else None
)

elif e.end >= f and e.start <= t:
add_if_not_exception(e)
add_if_not_exception(e, component if include_component else None)

result = found.copy()

Expand Down