import workdays # pip install workdays import datetime # holidays from https://www.timeanddate.com/holidays/us/2021 holidays = [(lambda x: datetime.datetime.strptime(x ,"%Y-%m-%d").date() ) (x) for x in [ "2017-01-01","2017-05-29","2017-07-04","2017-09-04","2017-11-24","2017-11-25","2017-12-25", "2018-01-01","2018-05-28","2018-07-04","2018-09-03","2018-11-22","2018-11-23","2018-12-25", "2019-01-01","2019-05-27","2019-07-04","2019-09-02","2019-11-28","2019-11-29","2019-12-25" "2020-01-01","2020-05-25","2020-07-03","2020-09-07","2020-11-26","2020-11-27","2020-12-25" "2020-12-31","2021-05-31","2021-07-05","2021-09-06","2021-11-25","2021-11-26","2021-12-25" "2021-12-31","2022-05-30","2022-07-04","2022-09-05","2022-11-24","2022-11-25","2022-12-24" "2023-01-02","2023-05-29","2023-07-04","2023-09-04","2023-11-22","2023-11-23","2023-12-26" "2024-01-01","2024-05-27","2024-07-04","2024-09-02","2024-11-28","2024-11-29","2024-12-25" "2025-01-01","2025-05-26","2025-07-04","2025-09-01","2025-11-27","2025-11-28","2025-12-25" ]] max(workdays.networkdays(datetime.datetime.strptime(boat["fabEnd"],"%Y-%m-%d").date(), datetime.datetime.strptime(boat["paintStart"],"%Y-%m-%d").date(), holidays) -2, 0) start = datetime.datetime.strptime('03-15-2017','%m-%d-%Y').date() end = datetime.datetime.strptime('03-27-2017','%m-%d-%Y').date() print "Number of workdays %g" % workdays.networkdays(start, end, holidays)