Include launches with unknown time as day events in calendar

This commit is contained in:
Edward Betts 2023-11-25 10:08:49 +00:00
parent b654e75cf5
commit 5d5b9016d1

View file

@ -265,14 +265,20 @@ async def get_data(now: datetime) -> typing.Mapping[str, str | object]:
events += domains.renewal_dates(my_data) events += domains.renewal_dates(my_data)
for launch in rockets: for launch in rockets:
if not launch["t0_time"]: dt = None
continue
dt = pytz.utc.localize(datetime.strptime(launch["net"], "%Y-%m-%dT%H:%M:%SZ")) if launch["net_precision"] == "Day":
e = Event( dt = datetime.strptime(launch["net"], "%Y-%m-%dT00:00:00Z").date()
name="rocket", elif launch["t0_time"]:
date=dt, dt = pytz.utc.localize(
title=f'🚀{launch["rocket"]}: {launch["mission"]["name"]}', datetime.strptime(launch["net"], "%Y-%m-%dT%H:%M:%SZ")
) )
if not dt:
continue
rocket_name = f'🚀{launch["rocket"]}: {launch["mission"]["name"]}'
e = Event(name="rocket", date=dt, title=rocket_name)
events.append(e) events.append(e)
events.sort(key=operator.attrgetter("as_datetime")) events.sort(key=operator.attrgetter("as_datetime"))