Skip to content

Instantly share code, notes, and snippets.

@sleekslush
Last active December 11, 2015 05:08
Show Gist options
  • Save sleekslush/4549597 to your computer and use it in GitHub Desktop.
Save sleekslush/4549597 to your computer and use it in GitHub Desktop.
Stupid datetime crap
import calendar
from datetime import timedelta
def get_end_of_month(date):
return date.replace(day=calendar.mdays[date.month])
def get_start_of_month(date):
return date.replace(day=1)
def get_prev_month(date):
return get_start_of_month(date) - timedelta(days=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment