Skip to content
Open
Changes from 1 commit
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
15 changes: 13 additions & 2 deletions vobject/icalendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,12 +430,23 @@ def getrruleset(self, addRDate=False):
logging.error('failed to find DUE at all.')
return None

if isinstance(dtstart, datetime.datetime):
dtstart_tzinfo = dtstart.tzinfo
else:
dtstart_tzinfo = None
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this into the if name in DATENAMES: clause since it is only used in that case.

if name in DATENAMES:
if type(line.value[0]) == datetime.datetime:
list(map(addfunc, line.value))
for dt in line.value:
if dtstart_tzinfo is None:
addfunc(dt.replace(tzinfo=None))
else:
addfunc(dt)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move the test outside the loop. This makes the code more efficient.

Same below.

elif type(line.value[0]) == datetime.date:
for dt in line.value:
addfunc(datetime.datetime(dt.year, dt.month, dt.day))
if isinstance(dtstart, datetime.datetime):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this test different from the one for datetime (line 440)?

addfunc(dtstart.replace(dt.year, dt.month, dt.day))
else:
addfunc(datetime.datetime(dt.year, dt.month, dt.day, tzinfo=dtstart_tzinfo))
else:
# ignore RDATEs with PERIOD values for now
pass
Expand Down