Changeset - 61086c244299
[Not reviewed]
0 1 0
Lance Edgar (lance) - 7 years ago 2017-11-12 09:49:34
lance@edbob.org
Add `time.date_range()` convenience function
1 file changed with 10 insertions and 0 deletions:
0 comments (0 inline, 0 general)
rattail/time.py
Show inline comments
 
@@ -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)
0 comments (0 inline, 0 general)