Answer the question
In order to leave comments, you need to log in
How to detect Russian holidays and weekends in python?
How to detect Russian holidays and weekends in python? Are there any ready-made solutions?
Answer the question
In order to leave comments, you need to log in
Parse some resource with a production calendar, and write a check method, something like this:
YEAR_HOLIDAYS = 'HOLIDAYS:{year}'
...
@classmethod
def is_work_day(cls, date):
if date.weekday() in [5,6]:
return False
holidays = cache.get(YEAR_HOLIDAYS.format(year=date.year))
if not holidays:
holidays = cls.objects.filter(year=date.year).values_list('date', flat=True)
cache.set(YEAR_HOLIDAYS.format(year=date.year), holidays)
if date in holidays:
return False
return True
How to find out the date which will be in n days, where n is excluding weekends, after a certain date in python?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question