Closed christopherdcunha closed 5 years ago
Ping @erwaller (I'm assuming you're a core contributor). Is there anything extra I need to do to get this reviewed?
Thanks for this @christopherdcunha and sorry for the long delay!
Looks like these are the UK holidays through end of 2019? Is the list usually published ~one year in advance?
No worries for the delay @erwaller and thanks for merging!
Yes, it seems that only one year's worth of holidays is published on https://www.gov.uk (i.e. at the moment, holidays up to 2020-12-31 are published). I'm not 100% sure that all these days are discoverable by code, BUT I can see that this is what python-holidays does.
As suggested by @le01phuo, it might be easier to defer this to another library (like python-holidays) and users of your library should be asked to do something like this:
from businesstime.holidays import Holidays
import holidays
class EnglandHolidays(Holidays):
holidays = holidays.England()['2012-1-1': '2020-12-31']
def isholiday(self, dt):
if isinstance(dt, datetime.datetime):
return dt.date() in self.holidays
return dt in self.holidays
EDIT: One quirk about the python-holidays library is that it seems to flag holidays that occur on weekends even though they've been substituted for weekdays in practice. e.g. NYE occurs on a Sunday, so the actual holiday will be on the Monday (Jan 2).
This PR will conflict with https://github.com/seatgeek/businesstime/pull/30
As @le01phuo mentions in his PR. The holidays package is probably a better option.