Adds a given number of months to a date, represented as the number of
days since the epoch.
496721
public static int addMonths(int date, int m) {
		int y0 = (int) DateTimeUtils.unixDateExtract(TimeUnitRange.YEAR, date);
		int m0 = (int) DateTimeUtils.unixDateExtract(TimeUnitRange.MONTH, date);
		int d0 = (int) DateTimeUtils.unixDateExtract(TimeUnitRange.DAY, date);
		int y = m / 12;
		y0 += y;
		m0 += m - y * 12;
		int last = lastDay(y0, m0);
		if (d0 > last) {
			d0 = 1;
			if (++m0 > 12) {
				m0 = 1;
				++y0;
			}
		}
		return DateTimeUtils.ymdToUnixDate(y0, m0, d0);
	}
705851
def add_years(datetime_like_object, n, return_date=False):
    
    a_datetime = parser.parse_datetime(datetime_like_object)

    # try assign year, month, day
    try:
        a_datetime = datetime(
            a_datetime.year + n, a_datetime.month, a_datetime.day,
            a_datetime.hour, a_datetime.minute, a_datetime.second,
            a_datetime.microsecond, tzinfo=a_datetime.tzinfo,
        )
    except ValueError:  # Must be xxxx-02-29
        a_datetime = datetime(
            a_datetime.year + n, 2, 28,
            a_datetime.hour, a_datetime.minute,
            a_datetime.second, a_datetime.microsecond)

    if return_date:  # pragma: no cover
        return a_datetime.date()
    else:
        return a_datetime
642040
public static Date plusMonths(Date date, int months) {
		return plus(date, months, DateTimeField.MONTH);
	}
1143785
def _adjust_n_months(other_day, n, reference_day):
    
    if n > 0 and other_day < reference_day:
        n = n - 1
    elif n <= 0 and other_day > reference_day:
        n = n + 1
    return n
330635
private int getMonthLength(int year, int month) {
        int days = DAYS_IN_MONTH[month];
        if (month == FEBRUARY && isLeapYear(year)) {
            days++;
        }
        return days;
    }
1024434
def edate(ctx, date, months):
    
    return conversions.to_date_or_datetime(date, ctx) + relativedelta(months=conversions.to_integer(months, ctx))
1122287
public static Date addDays(Date d, int days) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(d);
        cal.add(Calendar.DAY_OF_YEAR, days);
        return cal.getTime();
    }
154843
public static <D extends Comparable> DateTimeExpression<D> addDays(DateTimeExpression<D> date, int days) {
        return Expressions.dateTimeOperation(date.getType(), Ops.DateTimeOps.ADD_DAYS, date, ConstantImpl.create(days));
    }
736937
public DateFuncSup add(def<DateSeperator> dateFunction) {
                date.setTime(date.getTime() + dateFunction.apply(new DateSeperator()).parse());
                return this;
        }
460290
public static function addDays($date, $days) {
        if (Validator::isDateTime($date) === false) throw new InvalidArgumentException('Invalid argument $date: '.$date);
        if (!is_int($days))                         throw new IllegalTypeException('Illegal type of parameter $days: '.gettype($days));

        $parts = explode('-', $date);
        $year  = (int) $parts[0];
        $month = (int) $parts[1];
        $day   = (int) $parts[2];

        return date('Y-m-d', mktime(0, 0, 0, $month, $day+$days, $year));
    }
1036313
function incrementDays(date, numberOfDays) {
      return new Date(date.getFullYear(), date.getMonth(), date.getDate() + numberOfDays);
    }
731678
function dateAdd (date, interval, units) {
  let result = new Date(date)

  switch (interval.toLowerCase()) {
    case 'year':
      result.setFullYear(result.getFullYear() + units)
      break
    case 'quarter':
      result.setMonth(result.getMonth() + 3 * units)
      break
    case 'month':
      result.setMonth(result.getMonth() + units)
      break
    case 'week':
      result.setDate(result.getDate() + 7 * units)
      break
    case 'day':
      result.setDate(result.getDate() + units)
      break
    case 'hour':
      result.setTime(result.getTime() + units * 3600000)
      break
    case 'minute':
      result.setTime(result.getTime() + units * 60000)
      break
    case 'second':
      result.setTime(result.getTime() + units * 1000)
      break
    default:
      result = undefined
      break
  }
  return result
}
4764
def to_jd(year, month, day):
    ''''''
    return (day + ceil(29.5 * (month - 1)) + (year - 1) * 354 + trunc((3 + (11 * year)) / 30) + EPOCH) - 1
241927
private Date addDays(final Date date, final int days) {
        final Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        cal.add(Calendar.DATE, days); //minus number would decrement the days
        return cal.getTime();
    }
302211
def to_jd(year, month, day):
    ''''''
    legal_date(year, month, day)
    gyear = year + YEAR_EPOCH - 1

    return (
        gregorian.EPOCH - 1 + (365 * (gyear - 1)) +
        floor((gyear - 1) / 4) + (-floor((gyear - 1) / 100)) +
        floor((gyear - 1) / 400) + (month - 1) * 28 + day
    )
1130145
def date(ctx, year, month, day):
    
    return _date(conversions.to_integer(year, ctx), conversions.to_integer(month, ctx), conversions.to_integer(day, ctx))
1306817
def offset(self, date, n_days):
        '''
        
        '''
#CONSIDER: raise an exception if a date is not in self
        index = self.index(date) + n_days
        if index < 0:
            index = 0
        if index > len(self) - 1:
            index = len(self) - 1
        return self[index]