Compare commits

..

No commits in common. "bda05d214cc7217458854f6335719f8d83a8538e" and "cb7f7536a939d844dfb3f4274ae9904943779071" have entirely different histories.

2 changed files with 7 additions and 5 deletions

View file

@ -119,7 +119,7 @@ def timezone_transition(
] ]
async def get_next_bank_holiday(start_date: date, end_date: date) -> list[Event]: async def get_next_bank_holiday(input_date: date) -> list[Event]:
"""Date and name of the next UK bank holiday.""" """Date and name of the next UK bank holiday."""
url = "https://www.gov.uk/bank-holidays.json" url = "https://www.gov.uk/bank-holidays.json"
filename = os.path.join(data_dir, "bank-holidays.json") filename = os.path.join(data_dir, "bank-holidays.json")
@ -129,13 +129,15 @@ async def get_next_bank_holiday(start_date: date, end_date: date) -> list[Event]
r = await client.get(url) r = await client.get(url)
open(filename, "w").write(r.text) open(filename, "w").write(r.text)
year_later = input_date + timedelta(days=365)
events = json.load(open(filename))["england-and-wales"]["events"] events = json.load(open(filename))["england-and-wales"]["events"]
hols: list[Event] = [] hols: list[Event] = []
for event in events: for event in events:
event_date = datetime.strptime(event["date"], "%Y-%m-%d").date() event_date = datetime.strptime(event["date"], "%Y-%m-%d").date()
if event_date < start_date: if event_date < input_date:
continue continue
if event_date > end_date: if event_date > year_later:
break break
hols.append(Event(name="bank_holiday", date=event_date, title=event["title"])) hols.append(Event(name="bank_holiday", date=event_date, title=event["title"]))
@ -327,7 +329,7 @@ async def get_data(now: datetime) -> typing.Mapping[str, str | object]:
) = await asyncio.gather( ) = await asyncio.gather(
fx.get_gbpusd(config), fx.get_gbpusd(config),
gwr.advance_ticket_date(data_dir), gwr.advance_ticket_date(data_dir),
get_next_bank_holiday(last_year, next_year), get_next_bank_holiday(today),
thespacedevs.get_launches(rocket_dir, limit=40), thespacedevs.get_launches(rocket_dir, limit=40),
) )

View file

@ -1,4 +1,4 @@
"""Waste collection schedules.""" #!/usr/bin/python3
import json import json
import os import os