import calendar


def increment_months(orig_date, inc):
    
    """
    The increment_months() function advances or reduces month in a datetime
    object.
    
    -- orig_date: datetime object to be changed. 
    
    -- inc: number of months to increment. Accepts signed integer 
    to increment or decrement.
    """
    
    new_year = orig_date.year
    new_month = orig_date.month + inc
    # note: in datetime.date, months go from 1 to 12
    # conditional advances year if necessary 
    if new_month > 12:
        new_year += 1
        new_month -= 12
    elif new_month < 1:
        new_year -= 1
        new_month += 12

    last_day_of_month = calendar.monthrange(new_year, new_month)[1]
    new_day = min(orig_date.day, last_day_of_month)

    return orig_date.replace(year=new_year, month=new_month, day=new_day)