byeaster and bysetpos can't be used together
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.
I can also create another object like this:
>>> byeaster = rrule(freq=0, byeaster=182)
>>> byeaster[0]
datetime.
But, if I combine those rules, I get an exception:
>>> easter_and_setpos = rrule(freq=0, byeaster=182, byweekday=6, bysetpos=-13)
>>> easter_
Traceback (most recent call last):
File "/Users/
res = advance_
StopIteration
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/
raise IndexError
IndexError
Is this intentional or a bug?
description: | updated |
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.