Skip to content

Instantly share code, notes, and snippets.

@timbirk
Created July 20, 2018 13:15
Show Gist options
  • Save timbirk/024a26c93aabbfadee802c7c5bb5bca1 to your computer and use it in GitHub Desktop.
Save timbirk/024a26c93aabbfadee802c7c5bb5bca1 to your computer and use it in GitHub Desktop.
Python script to detect if it's a UK bank holiday. Requires "holidays" pip package.
#!/usr/bin/env python
import sys
import holidays
from datetime import date
sys.exit(date.today() not in holidays.England())
@timbirk
Copy link
Author

timbirk commented Jul 20, 2018

Many times I've needed to run or not run tasks (cron jobs, bank uploads / reports) with an awareness to bank holidays. A consultancy quoted a lot of money and 3 months to build a java service to do it... Python to the rescue!.

@timbirk
Copy link
Author

timbirk commented Jul 30, 2018

I've released a better version of this to PyPi as a package: https://pypi.org/project/publicholiday/

which handles all countries supported by: https://pypi.org/project/holidays/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment