<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _add_months(p_sourcedate, p_months):
 """ Adds a number of months to the source date. Takes into account shorter months and leap years and such. https://stackoverflow.com/questions/4130922/how-to-increment-datetime-month-in-python """

    month = p_sourcedate.month - 1 + p_months
    year = p_sourcedate.year + month // 12
    month = month % 12 + 1
    day = min(p_sourcedate.day, calendar.monthrange(year, month)[1])

    return date(year, month, day)