diff --git a/agenda/__init__.py b/agenda/__init__.py index d6ec273..46bd82d 100644 --- a/agenda/__init__.py +++ b/agenda/__init__.py @@ -13,6 +13,7 @@ from typing import List import dateutil import dateutil.parser import dateutil.tz +import ephem import exchange_calendars import holidays import lxml @@ -593,6 +594,22 @@ def waste_collection_events() -> list[Event]: return events +def bristol(): + observer = ephem.Observer() + observer.lat, observer.lon = "51.4545", "-2.5879" + return observer + + +def sunrise(observer): + """Sunrise.""" + return observer.next_rising(ephem.Sun(observer)).datetime() + + +def sunset(observer): + """Sunrise.""" + return observer.next_setting(ephem.Sun(observer)).datetime() + + def get_data(now: datetime) -> typing.Mapping[str, str | object]: """Get data to display on agenda dashboard.""" rocket_dir = os.path.join(data_dir, "thespacedevs") @@ -634,6 +651,10 @@ def get_data(now: datetime) -> typing.Mapping[str, str | object]: event = Event(name=key, date=value) events.append(event) + observer = bristol() + reply["sunrise"] = sunrise(observer) + reply["sunset"] = sunset(observer) + for key, value in xmas_last_posting_dates.items(): events.append(Event(name=f"xmas_last_{key}", date=value)) diff --git a/templates/index.html b/templates/index.html index 33ebeb6..9755093 100644 --- a/templates/index.html +++ b/templates/index.html @@ -55,6 +55,8 @@ unknown {% endif %} +