Skip to content

Instantly share code, notes, and snippets.

@mechanicalgirl
Created April 4, 2013 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mechanicalgirl/5312503 to your computer and use it in GitHub Desktop.
Save mechanicalgirl/5312503 to your computer and use it in GitHub Desktop.
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)
else:
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