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/actions/workflows/test.yml/badge.svg?branch=main

Please report bugs and open pull requests on GitHub.

To work on changes to this library, it’s recommended to install it in editable mode into a virtual environment, i.e. pip install --editable .

Update cached bank holidays from GOV.UK using python scripts/update-cache.py.

Update translation files using python scripts/messages.py update, e.g. when updating the i18n module or when adding new languages. Compile them using python scripts/messages.py compile; this is required before testing and distribution. Updating and compiling translation files requires the gettext system package to be installed.

Use python -m tests to run all tests locally. Alternatively, you can use tox if you have multiple python versions.

[Only for GitHub team members] Distribute a new version to PyPI by:

  • updating the VERSION tuple in govuk_bank_holidays/__init__.py

  • adding a note to the History

  • publishing a release on GitHub which triggers an upload to PyPI; alternatively, run python scripts/messages.py compile; python -m build; twine upload dist/* locally

History

0.19

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

0.18

Added support for python 3.14 and removed 3.9 which has reached end-of-life. Migrated to trusted publishing.

0.17

Added timeout for source downloads (default being GOV.UK) before falling back to cache.

0.16

Removed support for python versions older than 3.9 since they have reached end-of-life and are not available for testing in Github Actions. Added python 3.13 to testing matrix. Updated cached bank holidays file to include latest holidays published by GOV.UK.

0.15

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

0.14

Migrated test, build and release processes away from deprecated setuptools commands. Translation files are updated and compiled through scripts which are not included in distribution. The BankHolidays class has a new ALL_DIVISIONS constant.

0.13

The library does not differ from 0.12.

0.12

Removed support for python versions older than 3.7. Updated cached bank holidays file to include latest holidays published by GOV.UK. Moved code style linting from unit test to github action. Added setup.py command to update cached bank holidays from GOV.UK.

0.11

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

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.19.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

govuk_bank_holidays-0.19-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file govuk_bank_holidays-0.19.tar.gz.

File metadata

  • Download URL: govuk_bank_holidays-0.19.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for govuk_bank_holidays-0.19.tar.gz
Algorithm Hash digest
SHA256 01aabb85968bebb6c91b2fda21e14c0179328e003ab48f2f543318114273edf6
MD5 b3b81262a8df70a77a191280b261a785
BLAKE2b-256 b6b759ecbef6a66d9281dfca4fcf9afda630354bcc24698d7338fc24ed065b79

See more details on using hashes here.

Provenance

The following attestation bundles were made for govuk_bank_holidays-0.19.tar.gz:

Publisher: release.yml on ministryofjustice/govuk-bank-holidays

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for govuk_bank_holidays-0.19-py3-none-any.whl
Algorithm Hash digest
SHA256 8825af86d98c8da26e4485fa44b50b8dcfca8dc051387984c79008308501bc17
MD5 9793882e4b6a003e3ab8bed313ac45b3
BLAKE2b-256 f2becf1c406a591a81df20bb2a8b51f78fa2d86524d3ce3bd5525a204c01a835

See more details on using hashes here.

Provenance

The following attestation bundles were made for govuk_bank_holidays-0.19-py3-none-any.whl:

Publisher: release.yml on ministryofjustice/govuk-bank-holidays

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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