Show end of the UK financial year in past

This commit is contained in:
Edward Betts 2023-11-08 13:29:40 +01:00
parent 2fc200c7b2
commit a109af2536

View file

@ -59,23 +59,7 @@ def timezone_transition(
]
def uk_financial_year_end(input_date: date) -> date:
"""Next date of the end of the UK financial year, April 5th."""
# Determine the year of the input date
year = input_date.year
# Calculate the UK financial year end date (April 5th)
uk_financial_year_end = date(year, 4, 5)
# If the input date is on or after the UK financial year end date,
# move to the next year
if input_date > uk_financial_year_end:
uk_financial_year_end = date(year + 1, 4, 5)
return uk_financial_year_end
def uk_financial_year_ends(start_date: date, end_date: date) -> list[Event]:
def uk_financial_year_end(start_date: date, end_date: date) -> list[Event]:
"""Generate a list of UK financial year end dates (April 5th) between two dates."""
# Initialize an empty list to store the financial year ends
financial_year_ends: list[date] = []
@ -230,7 +214,7 @@ async def get_data(now: datetime) -> typing.Mapping[str, str | object]:
),
"mothers_day": uk_holiday.get_mothers_day(today),
"fathers_day": uk_holiday.get_fathers_day(today),
"uk_financial_year_end": uk_financial_year_end(today),
"uk_financial_year_end": uk_financial_year_end(last_year, next_year),
"xmas_last_posting_dates": xmas_last_posting_dates,
"gwr_advance_tickets": gwr_advance_tickets,
"critical_mass": critical_mass(last_year, next_year),