Last active
December 11, 2015 05:08
-
-
Save sleekslush/4549597 to your computer and use it in GitHub Desktop.
Stupid datetime crap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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