Skip to content
Snippets Groups Projects

Resolve "Problems with dates which are in the new year, but in the last calendar week of the old year"

All threads resolved!
1 file
+ 7
1
Compare changes
  • Side-by-side
  • Inline
@@ -64,7 +64,13 @@ 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
+1
if (when.month == 52 or when.month == 53) and when.month == 1:
year -= 1
return cls(year=year, week=week)
Loading