I am using the rrule method from python-dateutil package. I would like to create a rule that can ignore dates that are within a holiday calendar. I know about the exdate() method but this seems to filter the date from the output list only it has been generated.
from dateutil.rrule import *
from datetime import datetime
set = rruleset()
set.rrule(rrule(MONTHLY, count=4, bysetpos=-1, byweekday=(MO, TU, WE, TH, FR), dtstart=datetime(2013, 1, 1)))
print(list(set))
# outputs 4 dates without an exdate() call
# print : [datetime.datetime(2013, 1, 31, 0, 0), datetime.datetime(2013, 2, 28, 0, 0), datetime.datetime(2013, 3, 29, 0, 0), datetime.datetime(2013, 4, 30, 0, 0)]
set.exdate(datetime(2013, 2, 28, 0, 0))
list(set)
# only outputs 3 dates, ignoring the date provided in exdate()
# print : [datetime.datetime(2013, 1, 31, 0, 0), datetime.datetime(2013, 3, 29, 0, 0), datetime.datetime(2013, 4, 30, 0, 0)]
What I would like rrule to do is not omit the datetime(2013, 2, 28, 0, 0) but instead seek back to find the next best date according to the original rules, i.e. in this case datetime(2013, 2, 27, 0, 0). Any ideas how I could achieve this?