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

Fix year detection at year turns

parent f897f5f4
No related branches found
No related tags found
1 merge request!6Resolve "Problems with dates which are in the new year, but in the last calendar week of the old year"
...@@ -64,7 +64,12 @@ class CalendarWeek: ...@@ -64,7 +64,12 @@ class CalendarWeek:
""" Get the calendar week by a date object (the week this date is in). """ """ Get the calendar week by a date object (the week this date is in). """
week = int(when.strftime("%V")) 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) return cls(year=year, week=week)
......
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