Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
def _month_bounds(date):
Helper: return the first and last days of the month for the given date.
first_day = date.replace(day=1)
if first_day.month == 12:
last_day = first_day.replace(year=first_day.year + 1, month=1)
last_day = first_day.replace(month=first_day.month + 1)
return first_day, last_day
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment