Show upcoming conferences

Closes: #2
This commit is contained in:
Edward Betts 2023-10-07 10:56:06 +01:00
parent 8e6c617277
commit 9456228895

View file

@ -8,6 +8,7 @@ import warnings
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal
from time import time as unixtime
from typing import List
import dateutil
import dateutil.parser
@ -16,6 +17,7 @@ import holidays
import pandas
import pytz
import requests
import yaml
from dateutil.easter import easter
from agenda import thespacedevs
@ -278,6 +280,28 @@ def get_us_holidays(input_date: date) -> list[Event]:
]
def get_conferences(input_date: date, filepath: str) -> List[Event]:
"""Read conferences from a YAML file and return a list of Event objects."""
with open(filepath, "r") as f:
data = yaml.safe_load(f)
events = []
for conf in data.get("conferences", []):
event_date = conf["start"]
# Skip the conference if it is before the input date.
if event_date < input_date:
continue
event = Event(
name="conference",
date=event_date,
title=f'{conf["name"]} ({conf["location"]})',
)
events.append(event)
return events
def next_birthday(from_date: date, birth_date: date) -> tuple[date, int]:
"""Calculate the date of the next birthday based on a given birth date."""
next_birthday_date = birth_date.replace(year=from_date.year)
@ -349,6 +373,7 @@ def get_data(now: datetime) -> dict[str, str | object]:
events.append(Event(name=f"xmas_last_{key}", date=value))
events += get_birthdays(today, config)
events += get_conferences(today, "conferences.yaml")
next_up_series = Event(
date=date(2026, 6, 1),