parent
ec1694fc84
commit
f4c914a126
|
@ -374,6 +374,36 @@ def windmill_hill_market_days(start_date: date) -> list[Event]:
|
|||
return events
|
||||
|
||||
|
||||
def tobacco_factory_market_days(start_date: date) -> list[Event]:
|
||||
"""Tobacco Factory Market days for the next 12 months from a given date."""
|
||||
events: list[Event] = []
|
||||
current_date = start_date
|
||||
count = 0
|
||||
|
||||
tz = pytz.timezone("Europe/London")
|
||||
t = time(10, 0)
|
||||
|
||||
while count < 52: # 52 weeks in a year
|
||||
# Calculate the next Sunday from the current date
|
||||
next_sunday = current_date + relativedelta(weekday=6) # Sunday is 6
|
||||
|
||||
# Include it in the list only if it's on or after the start_date
|
||||
if next_sunday >= start_date:
|
||||
events.append(
|
||||
Event(
|
||||
name="market",
|
||||
title="Tobacco Factory Sunday Market",
|
||||
date=tz.localize(datetime.combine(next_sunday, t)),
|
||||
)
|
||||
)
|
||||
count += 1
|
||||
|
||||
# Move to the next week
|
||||
current_date += timedelta(weeks=1)
|
||||
|
||||
return events
|
||||
|
||||
|
||||
# Test the function
|
||||
if __name__ == "__main__":
|
||||
start_date = date(2023, 10, 29)
|
||||
|
@ -553,7 +583,7 @@ def get_data(now: datetime) -> typing.Mapping[str, str | object]:
|
|||
"xmas_last_posting_dates": xmas_last_posting_dates,
|
||||
"gwr_advance_tickets": find_gwr_advance_ticket_date(),
|
||||
"critical_mass": critical_mass(today),
|
||||
"market": windmill_hill_market_days(today),
|
||||
"market": windmill_hill_market_days(today) + tobacco_factory_market_days(today),
|
||||
"rockets": thespacedevs.get_launches(rocket_dir, limit=40),
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue