Expand description
§GOV.UK Bank Holidays
This library loads the official list of bank holidays in the United Kingdom as supplied by GOV.UK, which tends 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.
Bank holidays differ around the UK. The GOV.UK source currently lists these for 3 “divisions”:
- England and Wales
- Scotland
- Northern Ireland
Methods on BankHolidayCalendar
that take a division
parameter will consider bank holidays only for the provided
division (Some(Division)
) or only those that are common to all divisions for None
.
§Usage
use govuk_bank_holidays::prelude::*;
let date = Date::today();
// load bank holidays from GOV.UK
let calendar = BankHolidayCalendar::load().await;
// check if the given date is a bank holiday in _all_ divisions
let is_holiday = calendar.is_holiday(date, None);
println!("Is {date} a bank holiday across the UK? {is_holiday}");
// check if the given date is a work day in Northern Ireland
let is_work_day = calendar.is_work_day(date, Some(Division::NorthernIreland));
println!("Is {date} a work day in NI? {is_work_day}");
§Features
The date implementation is swappable:
chrono
and time
cannot be used together.
Modules§
- data_
source - Utilities for load and parsing bank holidays from GOV.UK.
- prelude
- Commonly-used items.
Structs§
- Bank
Holiday - Details of a bank holiday.
- Bank
Holiday Calendar - Calendar of known bank holidays.
- Date
- A date without time zone information.
Uses
chrono
ortime
crate’s implementation depending on feature flag. UseAsRef
orInto
to get the underlying type. - MonTo
FriWork Days - Typical working week, Monday to Friday.
Enums§
- Division
- Parts of the UK with shared bank holiday dates.
- Error
- Possible errors when handling dates and bank holidays.
- Weekday
- A day of the week from the Gregorian calendar.
Constants§
- SOURCE_
URL - Default URL to load bank holidays from.
Traits§
- Work
Days - Used by
BankHolidayCalendar
to determine if a given date is work day or not (typically, but not necessarily, the weekend).