Skip to content

Conversation

@da4089
Copy link

@da4089 da4089 commented Feb 23, 2024

Fixed exception 'TypeError: can't compare offset-naive and offset-aware datetimes' triggered when DTSTART and EXDATE not both have or not have timez one information. Fix will propagte time zone information from from DTSTART to EXDATE if EXDATE does not have a TZ or strip the TZ from EXDATE when DTSTART does not have time zone information.
@da4089 da4089 added this to the v1.0 milestone Mar 19, 2024
if isinstance(dtstart, datetime.datetime):
dtstart_tzinfo = dtstart.tzinfo
else:
dtstart_tzinfo = None
Copy link

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.

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

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)?

if dtstart_tzinfo is None:
addfunc(dt.replace(tzinfo=None))
else:
addfunc(dt)
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants