Add Circle line fare to Transfer column and Total
Add tfl_fare.py with circle_line_fare() which returns £3.10 (peak) or £3.00 (off-peak) based on TfL Zone 1 pricing. Peak applies Monday–Friday (excluding England public holidays) 06:30–09:30 and 16:00–19:00. Annotate each circle service with its fare in trip_planner.py, display it alongside the Circle line times in the Transfer column, and include it in the journey Total. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
89a536dfd3
commit
35097fda4f
4 changed files with 43 additions and 4 deletions
30
tfl_fare.py
Normal file
30
tfl_fare.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
"""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
|
||||
Loading…
Add table
Add a link
Reference in a new issue