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

Fix weeks_within to include all weeks

parent 6e5d016b
No related branches found
No related tags found
1 merge request!10Resolve "weeks_within(start, end) misses last week if the start weekday is bigger then the end weekday"
......@@ -7,6 +7,14 @@ The format is based on `Keep a Changelog <http://keepachangelog.com/>`__
and this project adheres to `Semantic
Versioning <http://semver.org/>`__.
0.5.3
-----
Fixed
~~~~~
* CalendarWeek.weeks_within missed last week if the start weekday was bigger then the end weekday
0.5.2
-----
......
......@@ -86,11 +86,14 @@ class CalendarWeek:
if start > end:
raise ValueError("End date must be after start date.")
current = start
start_week = cls.from_date(start)
end_week = cls.from_date(end)
current = start_week
weeks = []
while current < end:
weeks.append(cls.from_date(current))
current += timedelta(days=7)
while current <= end_week:
weeks.append(current)
current += 1
return weeks
......
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