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

Add method to get calendar weeks within date range.

parent 352087da
No related branches found
No related tags found
No related merge requests found
......@@ -28,6 +28,21 @@ class CalendarWeek:
return cls().week
@classmethod
def weeks_within(cls, start: date, end: date) -> Sequence[CalendarWeek]:
""" Get all calendar weeks within a date range. """
if start > end:
raise ValueError('End date must be after start date.')
current = start
weeks = []
while current < end:
weeks.append(cls.from_date(current))
current += timedelta(days=7)
return weeks
def __post_init__(self) -> None:
today = date.today()
......
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