Skip to main content

Tool to load UK bank holidays from GOV.UK

Project description

This library loads the official list of bank holidays in the United Kingdom as supplied by GOV.UK. GOV.UK tend to provide this list for only a year or two into the future.

A cached backup list of known bank holidays is stored in this package though it is not updated often. GOV.UK no longer provide bank holidays for some of the older years still part of this backup list.

Usage

Install using pip install govuk-bank-holidays. Sample usage:

from govuk_bank_holidays.bank_holidays import BankHolidays

bank_holidays = BankHolidays()
for bank_holiday in bank_holidays.get_holidays():
    print(bank_holiday['title'], 'is on', bank_holiday['date'])
print(bank_holidays.get_next_holiday())

# see govuk_bank_holidays/bank_holidays.py source file for more methods and argument details…

# choose a different locale for holiday titles and notes
bank_holidays = BankHolidays(locale='cy')

# use cached holidays if internet connection is not desired
bank_holidays = BankHolidays(use_cached_holidays=True)

Bank holidays differ around the UK. The GOV.UK source currently lists these for 3 “divisions”:

  • England and Wales

  • Scotland

  • Northern Ireland

… and many methods in this library take a division parameter (see constants defined on BankHolidays class).

NB: If no division is specified, only holidays common to all divisions are returned so some local bank holidays may not be listed. Therefore specifying a division is recommended.

While localisation is provided in English (the default with locale code ‘en’) and Welsh (locale code ‘cy’), please note that the Welsh version may contain errors.

Development

https://github.com/ministryofjustice/govuk-bank-holidays/workflows/Run%20tests/badge.svg?branch=master

Please report bugs and open pull requests on GitHub.

Update translation files using python setup.py makemessages, e.g. when updating the i18n module or when adding new languages. Compile them using python setup.py compilemessages; this is required before testing and distribution.

Use python setup.py compilemessages test to run all tests locally. Alternatively, you can use tox if you have multiple python versions.

Distribute a new version by:

  • updating the VERSION tuple in govuk_bank_holidays

  • adding a note to the History

  • publishing a release on GitHub which triggers an upload to PYPI

Alternatively, run python setup.py compilemessages sdist bdist_wheel upload locally.

History

0.10

Added methods to generate series of holidays and work days before/after starting from a given date.

0.9

Added methods to find previous bank holidays / work days, mirroring the existing methods. Removed support for python versions older than 3.6. Added python 3.9 to testing matrix.

0.8

The library does not differ from 0.7. This release is the first to use GitHub Actions to automatically publish to PYPI.

0.7

Minor documentation update.

0.6

Updated cached bank holidays file to include latest holidays published by GOV.UK. Added python 3.8 to testing matrix. Minor documentation update.

0.5

Updated cached bank holidays file to include latest holidays published by GOV.UK.

0.4

Updated cached bank holidays file to include latest holidays published by GOV.UK. Added python 3.7 to testing matrix. Documentation improved.

0.3

Improved testing. Library unchanged.

0.2

Updated cached bank holidays file to include latest holidays published by GOV.UK. Added option to force use of cached file. Added next work day calculation.

0.1

Initial release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

govuk-bank-holidays-0.10.tar.gz (12.7 kB view details)

Uploaded Source

Built Distributions

govuk_bank_holidays-0.10-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

govuk_bank_holidays-0.10-py2.py3-none-any.whl (13.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file govuk-bank-holidays-0.10.tar.gz.

File metadata

  • Download URL: govuk-bank-holidays-0.10.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

File hashes

Hashes for govuk-bank-holidays-0.10.tar.gz
Algorithm Hash digest
SHA256 07123f2c48a8cfdb63f4b9006ae77e91f00eb8044a23a698ea47486a06dfc111
MD5 1928e84919057ed0e1cbfcb7c009f138
BLAKE2b-256 d331725e9abaaaa20774ac2bdfd52202e25f2d3c00d6c1b847ed20336a7da711

See more details on using hashes here.

File details

Details for the file govuk_bank_holidays-0.10-py3-none-any.whl.

File metadata

  • Download URL: govuk_bank_holidays-0.10-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.2

File hashes

Hashes for govuk_bank_holidays-0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 bc01d62b6af8b188758ce2bfbd1a402604f2cfd445c2ea9b506420a8aa81a219
MD5 d84c6cf3cdca76556c8ce7b9bf23f66b
BLAKE2b-256 94c24c41b8c5c1cd7db37983ffa0f570044f32265fb6073ebd4378285d600c32

See more details on using hashes here.

File details

Details for the file govuk_bank_holidays-0.10-py2.py3-none-any.whl.

File metadata

  • Download URL: govuk_bank_holidays-0.10-py2.py3-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

File hashes

Hashes for govuk_bank_holidays-0.10-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 cc42d441150f6f08adbed2fb3601dcc0cc7bf1ecb909a44a3a85fdb20861711b
MD5 474ad90b8db8c9e6bbb50d94e3569b29
BLAKE2b-256 2203598718192b4a91c917374d948d671e812ddfc735fa08377195dd6d8f4a88

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page