calendars

class uk_election_timetables.calendars.BankHolidayCalendar(dates)

Bases: object

A calendar that honours the standard 5-day week in addition to the input list of dates.

static create_matcher_from_entry(entry: dict) DateMatcher
exempted_dates()
class uk_election_timetables.calendars.Country(value)

Bases: Enum

The countries of the United Kingdom.

ENGLAND = 1
NORTHERN_IRELAND = 2
SCOTLAND = 3
WALES = 4
class uk_election_timetables.calendars.Region(value)

Bases: Enum

The regions of the United Kingdom and Gibraltar as elected in the EU Parliament

EAST_MIDLANDS = 1
EAST_OF_ENGLAND = 2
LONDON = 3
NORTHERN_IRELAND = 6
NORTH_EAST_ENGLAND = 4
NORTH_WEST_ENGLAND = 5
SCOTLAND = 7
SOUTH_EAST_ENGLAND = 8
SOUTH_WEST_ENGLAND = 9
WALES = 10
WEST_MIDLANDS = 11
YORKSHIRE_AND_THE_HUMBER = 12
class uk_election_timetables.calendars.UnitedKingdomBankHolidays

Bases: object

A representation of the bank holiday calendars in the United Kingdom.

This class exposes a function for each unique calendar: England & Wales, Northern Ireland, and Scotland.

england_and_wales() BankHolidayCalendar
Returns:

a calendar representation of bank holidays in England and Wales

from_country(country: Country) BankHolidayCalendar

Return the bank holiday calendar for the input country.

Parameters:

country – the country to retrieve the calendar for

Returns:

the corresponding calendar

northern_ireland() BankHolidayCalendar
Returns:

a calendar representation of bank holidays in Northern Ireland

scotland() BankHolidayCalendar
Returns:

a calendar representation of bank holidays in Scotland

uk_election_timetables.calendars.working_days_before(end_date: date, days: int, calendar: BankHolidayCalendar) date

Return date corresponding to count working days before poll_date according to the given bank holiday calendar

Parameters:
  • end_date – the date of the poll

  • days – the number of days before the poll date

  • calendar – the bank holiday calendar used in the calculation

Returns:

the calculated date