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

Add class method which gets the last week of a year

parent 1871c8c1
No related branches found
No related tags found
1 merge request!7Resolve "Introduce function to get the last week of a year"
...@@ -94,6 +94,13 @@ class CalendarWeek: ...@@ -94,6 +94,13 @@ class CalendarWeek:
return weeks return weeks
@classmethod
def get_last_week_of_year(cls, year: int) -> CalendarWeek:
"""Get the last week of a year."""
last_week = date(year, 12, 28).isocalendar()[1]
return cls(week=last_week, year=year)
def __post_init__(self) -> None: def __post_init__(self) -> None:
today = date.today() 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