Skip to content
Snippets Groups Projects
Verified Commit dea5c8db authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Document date utils

parent 635395d2
No related branches found
No related tags found
No related merge requests found
......@@ -8,19 +8,22 @@ from django.utils.translation import gettext_lazy as _
def week_weekday_from_date(when: date) -> Tuple[CalendarWeek, int]:
"""Return a tuple of week and weekday from a given date."""
return (CalendarWeek.from_date(when), when.weekday())
def week_weekday_to_date(week: CalendarWeek, weekday: int) -> date:
"""Return a date object for one day in a calendar week."""
return week[weekday - 1]
def week_period_to_date(week: Union[CalendarWeek, int], period) -> date:
"""Return the date of a lesson period in a given week."""
return period.get_date(week)
def get_weeks_for_year(year: int) -> List[CalendarWeek]:
""" Generates all weeks for one year """
"""Generate all weeks for one year."""
weeks = []
# Go for all weeks in year and create week list
......
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