date

class uk_election_timetables.date.DateMatcher(day: int, month: int, year: Optional[int] = None, name: Optional[str] = None)

Bases: object

An object that represents a matcher against datetime.date objects, given a day, a month, and an optional year.

matches(other: date) bool

Return whether the input date matches the attributes of this class

Parameters:

other – the date being matched against

Returns:

a boolean representing if the input date matches this class’s attributes

uk_election_timetables.date.days_before(poll_date: date, days: int, ignore: Optional[List[DateMatcher]] = None) date

Return date corresponding to days working days before poll_date, not counting the list of provided exemptions

Parameters:
  • poll_date – the date of the poll

  • days – the number of days before the poll date

  • ignore – the list of DateMatchers to ignore in the look-back calculation

Returns:

the calculated date