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

Fix CalendarWeek.from_date in this case: week == 1 and month == 12

parent e201434b
No related branches found
No related tags found
1 merge request!30Fix CalendarWeek.from_date in this case: week == 1 and month == 12
......@@ -20,7 +20,10 @@ class CalendarWeek:
def from_date(cls, when: date):
""" Get the calendar week by a date object (the week this date is in). """
return cls(year=when.year, week=int(when.strftime("%V")))
week = int(when.strftime("%V"))
year = when.year + 1 if when.month == 12 and week == 1 else when.year
return cls(year=year, week=week)
@classmethod
def current_week(cls) -> int:
......
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