From 0b78dcb7c635150e1370544ad728f16d1503b20d Mon Sep 17 00:00:00 2001
From: Jonathan Weth <git@jonathanweth.de>
Date: Sun, 12 Jan 2020 11:32:48 +0100
Subject: [PATCH] Fix CalendarWeek.from_date in this case: week == 1 and month
 == 12

---
 aleksis/apps/chronos/util.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/aleksis/apps/chronos/util.py b/aleksis/apps/chronos/util.py
index aebd2015..c9501c03 100644
--- a/aleksis/apps/chronos/util.py
+++ b/aleksis/apps/chronos/util.py
@@ -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:
-- 
GitLab