Add time.first_of_year() convenience function

This commit is contained in:
Lance Edgar 2019-02-11 17:43:26 -06:00
parent 4323fde854
commit 1719351495

View file

@ -183,6 +183,13 @@ def last_of_month(date):
return date.replace(day=last_day)
def first_of_year(date):
"""
Returns a date representing the first day of whichever year ``date`` falls in.
"""
return date.replace(month=1, day=1)
def date_range(start, end, step=1):
"""
Generator which yields all dates between ``start`` and ``end``, *inclusive*.