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

Merge branch 'fix-week' into 'master'

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

See merge request AlekSIS/AlekSIS-App-Chronos!30
parents e201434b 0b78dcb7
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