byeaster and bysetpos can't be used together

Bug #1402868 reported by Thomas Roten
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
dateutil
New
Undecided
Unassigned

Bug Description

I can create an rrule object like this:
    >>> bysetpos = rrule(freq=0, byweekday=6, bysetpos=-13)
    >>> bysetpos[0]
    datetime.datetime(2015, 10, 4, 14, 18, 5)

I can also create another object like this:
    >>> byeaster = rrule(freq=0, byeaster=182)
    >>> byeaster[0]
    datetime.datetime(2015, 10, 4, 14, 17, 56)

But, if I combine those rules, I get an exception:
    >>> easter_and_setpos = rrule(freq=0, byeaster=182, byweekday=6, bysetpos=-13)
    >>> easter_and_setpos[0]
    Traceback (most recent call last):
      File "/Users/tsr/.virtualenvs/sacredtime/lib/python3.4/site-packages/dateutil/rrule.py", line 144, in __getitem__
        res = advance_iterator(gen)
    StopIteration

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
       File "/Users/tsr/.virtualenvs/sacredtime/lib/python3.4/site-packages/dateutil/rrule.py", line 146, in __getitem__
         raise IndexError
     IndexError

Is this intentional or a bug?

Thomas Roten (tsroten)
description: updated
Revision history for this message
Paul G (p-ganssle) wrote :

I believe that this is not a problem. The first rule requests the set of all Sundays in a given year (there should be 52 or 53 of these), then selects the one 13th from the end.

The second rule requests the set of all days which are exactly 182 days after Easter (which happens to be the 13th Sunday from the end, in 2015).

The third rule requests the list of all Sundays which are exactly 182 days after Easter (there is exactly one of these), and chooses the 13th one from the end of that set - but the set is exactly 1 element long, so in any given year, there will never be a 13th-from-the-end Sunday-which-is-exactly-182-days-after-Easter. Thus, the rule is empty.

Revision history for this message
Paul G (p-ganssle) wrote :

Note: This issue has been migrated to Github here: https://github.com/dateutil/dateutil/issues/48

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.