Skip to content

Instantly share code, notes, and snippets.

@gfhuertac
Created May 2, 2018 20:46
Show Gist options
  • Save gfhuertac/b36bd91119827a36a13c3656c982ec23 to your computer and use it in GitHub Desktop.
Save gfhuertac/b36bd91119827a36a13c3656c982ec23 to your computer and use it in GitHub Desktop.
from datetime import datetime
import holidays
HOLIDAYS_IN_CHILE = holidays.HolidayBase()
""" Holidays in Chile """
HOLIDAYS_IN_CHILE.append(['2013-01-01', '2013-03-29', '2013-03-30', '2013-05-01', '2013-05-21',
'2013-06-27', '2013-07-16', '2013-08-15', '2013-09-17', '2013-09-18',
'2013-09-19', '2013-10-10', '2013-10-31', '2013-11-01', '2013-12-08', '2013-12-25'])
HOLIDAYS_IN_CHILE.append(['2014-01-01', '2014-04-18', '2014-04-19', '2014-05-01', '2014-05-21',
'2014-06-29', '2014-07-16', '2014-08-15', '2014-09-17', '2014-09-18',
'2014-09-19', '2014-10-12', '2014-10-31', '2014-11-01', '2014-12-08', '2014-12-25'])
HOLIDAYS_IN_CHILE.append(['2015-01-01', '2015-03-04', '2015-03-05', '2015-05-01', '2015-05-21',
'2015-07-02', '2015-07-16', '2015-08-15', '2015-09-17', '2015-09-18',
'2015-09-19', '2015-10-15', '2015-10-31', '2015-11-01', '2015-12-08', '2015-12-25'])
HOLIDAYS_IN_CHILE.append(['2016-01-01', '2016-03-25', '2016-03-26', '2016-05-01', '2016-05-21',
'2016-06-26', '2016-07-16', '2016-08-15', '2016-09-18', '2016-09-19',
'2016-10-12', '2016-10-31', '2016-11-01', '2016-12-08', '2016-12-25'])
HOLIDAYS_IN_CHILE.append(['2017-01-01', '2017-04-14', '2017-04-15', '2017-05-01', '2017-05-21',
'2017-06-26', '2017-07-16', '2017-08-15', '2017-09-18', '2017-09-19',
'2017-10-09', '2017-10-27', '2017-11-01', '2017-11-19', '2017-12-08', '2017-12-17', '2017-12-25'])
HOLIDAYS_IN_CHILE.append(['2018-01-01', '2018-03-30', '2018-03-31', '2018-05-01', '2018-05-21',
'2018-07-02', '2018-07-16', '2018-08-15', '2018-09-17', '2018-09-18',
'2018-09-19', '2018-10-15', '2018-11-01', '2018-11-02', '2018-12-08', '2018-12-25'])
def is_holiday(dtime, country=None):
if country is None:
return dtime.date() in HOLIDAYS_IN_CHILE or dtime.date().weekday() == 6
else:
return dtime.date() in holidays.Holidays(country=country)
test = datetime(2018, 5, 1)
print(is_holiday(test))
test = datetime(2018, 4, 30)
print(is_holiday(test))
test = datetime(2018, 4, 29)
print(is_holiday(test))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment