Returns the new date based on the inputted months.
    
    :param      date   | <datetime.date>
                months | <int>
    
    :return     <datetime.date>

def addMonths(date, months):
    """
    Returns the new date based on the inputted months.
    
    :param      date   | <datetime.date>
                months | <int>
    
    :return     <datetime.date>
    """
    # map from Qt information
    if type(date).__name__ in ('QDate', 'QDateTime', 'QTime'):
        date = date.toPython()

    mult = months / abs(months)
    years = mult * (abs(months) / 12)
    months = mult * (abs(months) % 12)

    # calculate the new month
    month = date.month + months
    if month < 1:
        years -= 1
        month = 12 - month

    elif 12 < month:
        years += 1
        month %= 12

    # calculate the new year
    year = date.year + years

    # calculate the new day
    check = datetime.date(year, month, 1)
    days = daysInMonth(check)

    return datetime.date(year, month, min(date.day, days))