Skip to content

Commit

Permalink
parameterize now param, plus fix bug where months got skipped
Browse files Browse the repository at this point in the history
  • Loading branch information
ebridges committed Feb 10, 2018
1 parent b402841 commit 3e1f275
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions accounting_reports/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ def csv_to_list(val):
return []


def list_of_months_from(begin):
def list_of_months_from(begin, end=datetime.now()):
"""
Returns a list of date objects beginning at the given `begin` up to the current month end.
"""
from_date = last_day_of_month(begin)
now = datetime.now()
until = datetime(now.year, now.month, now.day)
dates = map(last_day_of_month, [dt for dt in rrule(MONTHLY, dtstart=from_date, until=until)])
from_date = first_day_of_month(begin)
until = datetime(end.year, end.month, end.day)
dates = map(last_day_of_month,
[dt for dt in rrule(MONTHLY, dtstart=from_date, bymonthday=1, until=until)])
return list(dates)


Expand Down

0 comments on commit 3e1f275

Please sign in to comment.