"""TfL single fare calculations for journeys within Zone 1.""" from datetime import datetime, time import holidays CIRCLE_LINE_PEAK = 3.10 CIRCLE_LINE_OFF_PEAK = 3.00 _ENGLAND_HOLIDAYS = holidays.country_holidays("GB", subdiv="ENG") _AM_PEAK_START = time(6, 30) _AM_PEAK_END = time(9, 30) _PM_PEAK_START = time(16, 0) _PM_PEAK_END = time(19, 0) def circle_line_fare(depart_dt: datetime) -> float: """Return the TfL Circle line single fare for a given departure datetime. Peak (£3.10): Monday–Friday (excluding public holidays), 06:30–09:30 and 16:00–19:00. Off-peak (£3.00): all other times, weekends, and public holidays. """ if depart_dt.date() in _ENGLAND_HOLIDAYS or depart_dt.weekday() >= 5: return CIRCLE_LINE_OFF_PEAK t = depart_dt.time() if _AM_PEAK_START <= t < _AM_PEAK_END or _PM_PEAK_START <= t < _PM_PEAK_END: return CIRCLE_LINE_PEAK return CIRCLE_LINE_OFF_PEAK