diff --git a/CHANGELOG.rst b/CHANGELOG.rst index eade22c79acb28fc8f16eeb8bc62937e3976ad97..263ca6a72e34ddae68ef458c4b33045959fe1e27 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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 ----- diff --git a/calendarweek/calendarweek.py b/calendarweek/calendarweek.py index f02acf7b3395c5b3a37c1890d1eafe9b88476260..7d476a01e8ade8426fc9bd235c6f012a06be024e 100644 --- a/calendarweek/calendarweek.py +++ b/calendarweek/calendarweek.py @@ -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