Skip to content
Snippets Groups Projects
Commit face54c1 authored by Tilman Vatteroth's avatar Tilman Vatteroth :robot:
Browse files

* Tageberechnung verbessert.

parent b1f4a871
No related branches found
No related tags found
No related merge requests found
......@@ -104,14 +104,25 @@ class ProgramInfo:
requests.get(url="https://ufc.tu-dortmund.de/semesters/current.json").text
)
def get_next_event(self, day_diff, just_print=False):
def get_next_event(self, wanted_day_diff, just_print=False):
# Finde das nächste Event, dass nach heute ist und in `day_diff` Tagen stattfindet.
now = UTC.localize(
datetime.datetime.now()
)
for i in self.semester:
d = date_parser.parse(i["date"])
if d > now and (d - now).days <= day_diff:
if d < now:
continue
diff = (d - now)
if now.date() == d.date():
day_diff = 0
elif now.time() > d.time():
day_diff = diff.days + 1
elif now.time() <= d.time():
day_diff = diff.days
if d > now and day_diff <= wanted_day_diff:
if just_print:
pprint(i)
else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment