Adds (+/-) a number of months to the current date.

@param int Positive or negative number of months
@return AnDate
14280
public function addMonths($n)
    {
        $an = abs($n);
        $years = floor($an / 12);
        $months = $an % 12;

        if ($n < 0) {
            $this->year -= $years;
            $this->month -= $months;
            if ($this->month < 1) {
                $this->year--;
                $this->month = 12 + $this->month;
            }
        } else {
            $this->year += $years;
            $this->month += $months;
            if ($this->month > 12) {
                $this->year++;
                $this->month -= 12;
            }
        }

        return $this;
    }
1141847
public static <D extends Comparable> DateExpression<D> addMonths(DateExpression<D> date, int months) {
        return Expressions.dateOperation(date.getType(), Ops.DateTimeOps.ADD_MONTHS, date, ConstantImpl.create(months));
    }
1007612
public function addMonths($intMonths)
    {
        $prevDay = $this->Day;
        $this->Month += $intMonths;
        if ($this->Day != $prevDay) {
            $this->Day = 1;
            $this->addDays(-1);
        }
        return $this;
    }
1206316
public long add(long instant, long months) {
        int i_months = (int)months;
        if (i_months == months) {
            return add(instant, i_months);
        }

        // Copied from add(long, int) and modified slightly:

        long timePart = iChronology.getMillisOfDay(instant);

        int thisYear = iChronology.getYear(instant);
        int thisMonth = iChronology.getMonthOfYear(instant, thisYear);

        long yearToUse;
        long monthToUse = thisMonth - 1 + months;
        if (monthToUse >= 0) {
            yearToUse = thisYear + (monthToUse / iMax);
            monthToUse = (monthToUse % iMax) + 1;
        } else {
            yearToUse = thisYear + (monthToUse / iMax) - 1;
            monthToUse = Math.abs(monthToUse);
            int remMonthToUse = (int)(monthToUse % iMax);
            if (remMonthToUse == 0) {
                remMonthToUse = iMax;
            }
            monthToUse = iMax - remMonthToUse + 1;
            if (monthToUse == 1) {
                yearToUse += 1;
            }
        }

        if (yearToUse < iChronology.getMinYear() ||
            yearToUse > iChronology.getMaxYear()) {

            throw new IllegalArgumentException
                ("Magnitude of add amount is too large: " + months);
        }

        int i_yearToUse = (int)yearToUse;
        int i_monthToUse = (int)monthToUse;

        int dayToUse = iChronology.getDayOfMonth(instant, thisYear, thisMonth);
        int maxDay = iChronology.getDaysInYearMonth(i_yearToUse, i_monthToUse);
        if (dayToUse > maxDay) {
            dayToUse = maxDay;
        }

        long datePart =
            iChronology.getYearMonthDayMillis(i_yearToUse, i_monthToUse, dayToUse);
        return datePart + timePart;
    }
115345
public function Add( $duration )
	{
		if ( ! $duration instanceof DurationValue )
		{
			throw new \InvalidArgumentException();
		}

		$thisSeconds = $this->getTotalSeconds();
		$durationSeconds = $duration->getTotalSeconds();

		/**
		 * @var DecimalValue $interval
		 */
		$interval = $thisSeconds->Add( $durationSeconds );
		$hasValue = 0 > $interval->CompareTo( 0 ) != 0;
		$invert = 0 > $interval->CompareTo( 0 ) == -1;

		if ( ! $hasValue )
		{
			$di = new \DateInterval( $this->ZeroStringValue() );
			$di->hasValue = false;
			$di->microseconds = 0;
			return $di;
		}

		$di = new \DateInterval( "PT{$interval->getAbs()->getIntegerPart()}S" );

		// Normalize
		$dt = new \DateTimeImmutable();
		$diff = $dt->add( $di );
		$diff = $diff->diff( $dt );
		$diff->hasValue = true;
		$diff->invert = $invert;
		$diff->microseconds = $interval->getDecimalPart() + 0;
		// if ( $hasValue ) $this->type = XPATH20_DURATION_TYPE_DAYTIME;
		$this->Value = $diff;
	}
580830
@Override
    public ChronoPeriod plus(TemporalAmount amountToAdd) {
        ChronoPeriodImpl amount = validateAmount(amountToAdd);
        return new ChronoPeriodImpl(
                chrono,
                Math.addExact(years, amount.years),
                Math.addExact(months, amount.months),
                Math.addExact(days, amount.days));
    }
805726
private static function get(int $value) : Month
    {
        static $values;

        if (! isset($values[$value])) {
            $values[$value] = new Month($value);
        }

        return $values[$value];
    }
653385
public static function fromNative()
    {
        $args = func_get_args();

        $year  = new Year($args[0]);
        $month = Month::fromNative($args[1]);
        $day   = new MonthDay($args[2]);

        return new static($year, $month, $day);
    }
686137
private void addMonth(int i) {
        Calendar cal = Calendar.getInstance();
        cal.set(getDisplayYear(), getDisplayMonth() - 1, 1);
        int month = cal.get(Calendar.MONTH) + 1;
        if (i > 0 && month == 12) {
            addYear(1);
        }

        if (i < 0 && month == 1) {
            addYear(-1);
        }
        cal.add(Calendar.MONTH, i);

        monthTextField.setText(String.valueOf(cal.get(Calendar.MONTH) + 1));

    }
416883
public function additiveInverse(): Decimal
    {
        if ($this->isZero()) {
            return $this;
        } elseif ($this->isNegative()) {
            $value = \substr($this->value, 1);
        } else { // if ($this->isPositive()) {
            $value = '-' . $this->value;
        }

        return new static($value, $this->scale);
    }
321981
public function negated() : Period
    {
        if ($this->isZero()) {
            return $this;
        }

        return new Period(
            - $this->years,
            - $this->months,
            - $this->days
        );
    }
1073893
public static Temporal edate(EvaluationContext ctx, Object date, Object months) {
        Temporal dateOrDateTime = Conversions.toDateOrDateTime(date, ctx);
        int _months = Conversions.toInteger(months, ctx);
        return dateOrDateTime.plus(_months, ChronoUnit.MONTHS);
    }
1062688
public function add( $value )
	{
		if( !isset( $this->value ) )
			return $this->value = $value;
		if( $value == $this->value )
			return -1;
		if( $value < $this->value )
		{
			if( $this->left )
				$this->left->add( $value );
			else
				$this->left = new ADT_Tree_BalanceBinaryNode( $this->balance, $value );
		}
		else if( $value > $this->value )
		{
			if( $this->right )
				$this->right->add( $value );
			else
				$this->right = new ADT_Tree_BalanceBinaryNode( $this->balance, $value );
		}
		if ($this->balance)
		{
			$bf = $this->getBalance();
			if( $bf <= -1 * $this->balance || $bf >= $this->balance )
				$this->balanceTree();
		}
	}
1160786
public void plusMonths(int delta)
    {
        if (delta != 0)
        {
            int result = getMonth() -1 + delta;
            setMonth(Math.floorMod(result, 12) + 1);
            plusYears(Math.floorDiv(result, 12));
        }
    }
596602
def _add_months(p_sourcedate, p_months):
    
    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)
804959
public function next($offset = 1)
    {
        $nextDateTime = clone $this->startDateTime;
        $nextDateTime->modify('+'.abs($offset).' months');
        return new Month($nextDateTime);
    }
1168906
def QA_util_add_months(dt, months):
    
    dt = datetime.datetime.strptime(
        dt, "%Y-%m-%d") + relativedelta(months=months)
    return(dt)