Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RRULE EXDATE TZID parameter parsing does not respect ignoretz #1218

Open
AlecRosenbaum opened this issue Jun 16, 2022 · 0 comments · May be fixed by #1219
Open

RRULE EXDATE TZID parameter parsing does not respect ignoretz #1218

AlecRosenbaum opened this issue Jun 16, 2022 · 0 comments · May be fixed by #1219

Comments

@AlecRosenbaum
Copy link

EXDATE parameter parsing was added with #859 / #410.

The parameter parsing, however, does not respect ignoretz=True. This becomes a problem when trying to use any of the utility methods on the rrule, such as .before(dt).

Here's an example:

>>> import dateutil.rrule
>>> import datetime
>>> now = datetime.datetime.now()
>>> rrule = dateutil.rrule.rrulestr("EXDATE;TZID=America/Denver:20220602T110000\nRRULE:FREQ=WEEKLY", dtstart=now, ignoretz=True)
>>> rrule.before(now)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/closeio/venv/lib/python3.8/site-packages/dateutil/rrule.py", line 206, in before
    for i in gen:
  File "/home/closeio/venv/lib/python3.8/site-packages/dateutil/rrule.py", line 1401, in _iter
    while exlist and exlist[0] < ritem:
  File "/home/closeio/venv/lib/python3.8/site-packages/dateutil/rrule.py", line 1338, in __lt__
    return self.dt < other.dt
TypeError: can't compare offset-naive and offset-aware datetimes

Prior to 2.8.x, this same snippet worked correctly and did not throw an error.

Version information:

$ python -c "import dateutil; print(dateutil.__version__)"
2.8.2
$ python --version
Python 3.8.10

I realize that 2.8.0 was released in 2019, but this change makes upgrading a bit difficult as the new EXDATE parameter parsing makes the behavior not backwards compatible. The workaround seems to be passing both a tz-aware datetime to dtstart and .before(dt) if there's a TZID included on EXDATE. Though it's sort of hard to tell beforehand if there's going to be a TZID parameter there.

I would expect that passing ignoretz=True torrulestr would make EXDATE parsing ignore any TZID.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant