Code Sample, a copy-pastable example if possible
Holiday(
name="Health and Sports Day", # TODO: shift to July 24 in 2020 for Olympics
month=10,
day=1,
start_date=Timestamp(2000, 1, 1),
offset=DateOffset(weekday=MO(2)),
# filter=do_not_allow_year_2020 # suggested enhancement
),
Problem description
When setting up a Holiday() descriptor, some holidays do not recur every year, but they recur most years.
For example, Health and Sport Day in Japan in the year 2020 is being shifted to July 24, but this is not easily expressed with a Holiday() rule (one can't use the observance parameter because offset is also defined).
If I could define another parameter, filter, which takes a datetime-like object as an argument and returns a bool, I could then just define my own general logic to handle this case without having to break apart the general rule. (So in the example above, the routine do_not_allow_year_2020 would check whether date.year != 2020.)
I believe this parameter could be added to the Holiday.dates function without extensive changes elsewhere. And it would simplify the writing of calendar rules for a number of countries.
Comment From: mroeschke
Thanks for the suggestion but from the lack of community or core developer interest this is likely not to be implemented so closing. Can reopen if there is renewed interest