from datetime import datetime
import calendar


def month_bounds(date=None):
    """
    Return month start and end datetimes
    """
    if date is None:
        date=datetime.now()
    firstday,lastday=calendar.monthrange(date.year,date.month)
    start=datetime(date.year,date.month,firstday,0,0,0)
    end=datetime(date.year,date.month,lastday,23,59,59)
    return (start,end)