Add time.date_range()
convenience function
This commit is contained in:
parent
e2c6caf7d4
commit
61086c2442
|
@ -170,3 +170,13 @@ def last_of_month(date):
|
|||
"""
|
||||
last_day = calendar.monthrange(date.year, date.month)[1]
|
||||
return date.replace(day=last_day)
|
||||
|
||||
|
||||
def date_range(start, end, step=1):
|
||||
"""
|
||||
Generator which yields all dates between ``start`` and ``end``, *inclusive*.
|
||||
"""
|
||||
date = start
|
||||
while date <= end:
|
||||
yield date
|
||||
date += datetime.timedelta(days=step)
|
||||
|
|
Loading…
Reference in a new issue