-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change Account.balance_iter to Account.daily_balance
- Loading branch information
Showing
5 changed files
with
115 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from datetime import date, timedelta | ||
|
||
|
||
def daterange(start_date: date, end_date: date): | ||
"""Iterate over a range of dates, inclusive of the start and end dates.""" | ||
return ( | ||
start_date + timedelta(days=x) for x in range((end_date - start_date).days + 1) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from datetime import date | ||
|
||
from dateutil.relativedelta import relativedelta | ||
|
||
from budge.date import daterange | ||
|
||
|
||
def test_daterange(): | ||
start_date = date(2022, 12, 28) | ||
end_date = start_date + relativedelta(weeks=1) | ||
|
||
dates = list(daterange(start_date, end_date)) | ||
|
||
assert dates == [ | ||
date(2022, 12, 28), | ||
date(2022, 12, 29), | ||
date(2022, 12, 30), | ||
date(2022, 12, 31), | ||
date(2023, 1, 1), | ||
date(2023, 1, 2), | ||
date(2023, 1, 3), | ||
date(2023, 1, 4), | ||
] |