diff --git a/calendarweek/calendarweek.py b/calendarweek/calendarweek.py index 264b0c43f3b087e1a37fee37f33fbbbe09ae176c..6065081f8f02cae3623530aa3d86ba7b68f43f5b 100644 --- a/calendarweek/calendarweek.py +++ b/calendarweek/calendarweek.py @@ -64,7 +64,12 @@ class CalendarWeek: """ Get the calendar week by a date object (the week this date is in). """ week = int(when.strftime("%V")) - year = when.year + 1 if when.month == 12 and week == 1 else when.year + year = when.year + + if when.month == 12 and week == 1: + year += 1 + elif when.month == 1 and (week == 52 or week == 53): + year -= 1 return cls(year=year, week=week)