Skip to content
Snippets Groups Projects
Verified Commit b74cdf4f authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Add get_prev_relevant_day

parent 417d3b78
No related branches found
No related tags found
1 merge request!31Biscuit merge. Closes #53.
......@@ -41,3 +41,20 @@ def get_next_relevant_day(day: Optional[date] = None, time: Optional[time] = Non
day = cw[weekday_min_]
return day
def get_prev_relevant_day(day: Optional[date] = None) -> date:
""" Returns previous day with lessons depending on date """
if day is None:
day = timezone.now().date()
cw = CalendarWeek.from_date(day)
if day.weekday() > weekday_max:
day = cw[weekday_max]
elif day.weekday() < weekday_min_:
cw -= 1
day = cw[weekday_max]
return day
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment