changes date by given amount of months

@api
@param   int  $months
@return  \stubbles\date\Date
346554
public function byMonths(int $months): Date
    {
        return $this->monthTo($this->originalDate->month() + $months);
    }
654479
public function addMonths($months)
    {
        $months = (int) $months;
        $interval = new DateInterval('P' . abs($months) . 'M');

        if ($months < 0) {
            $interval->invert = 1;
        }

        return $this->add($interval);
    }
839604
public function dontSeeDateIsInMonths($date, $months) {
        \PHPUnit_Framework_Assert::assertNotEquals($months, $this->_GetNow()->diffInMonths($this->_ParseDate($date), false));
    }
314341
public function setDate($year, $month, $day)
    {
        if (self::$_immutable) {
            self::$_immutable = false;
            $newDate = clone $this;
            $newDate->setDate($year, $month, $day);
            self::$_immutable = true;

            return $newDate;
        } else {
            return parent::setDate($year, $month, $day);
        }
    }
1095977
function setMonth( $month )
    {
        $arr = getdate( $this->DateTime );
        $this->DateTime = mktime( $arr['hours'], $arr['minutes'], $arr['seconds'],
                                  $month, $arr['mday'], $arr['year'] );
    }
912647
public function withDateAt(int $year = null, int $month = null, int $day = null) : self
    {
        if (null === $year && null === $month && null === $day) {
            return $this;
        }
        
        $year  = $year === null ? $this->year() : $year;
        $month = $month ?: $this->month();
        $day   = $day   ?: $this->day();
        
        $instance = clone $this;
        
        $instance->date->setDate($year, $month, $day);
        
        return $instance;
    }
277550
public function retrieveMonth($month) {
		if (!$month) {
			return 0;
		}
		$month = mb_strtolower($month);
		if (in_array($month, $this->monthList)) {
			$keys = array_keys($this->monthList, $month);
			return $keys[0] + 1;
		}
		return 0;
	}
1192668
public function addMonths($months)
    {
        if($months==0){
            return new DateTime($this->_time);
        }
        $year=$this->getYear();
        $month=$this->getMonth();
        $day=$this->getDay();
        if($months>0){
            $addYears=floor($months/12);
            $addMonths=$months%12;
            while ($addMonths+$month>12){
                $addYears++;
                $addMonths-=12;
            }
            $str=strval($year+$addYears)."-".strval($addMonths+$month)."-01";
            $lastDay = date("t",strtotime($str));//当月的最后一天
            if($day>$lastDay){
                $day=$lastDay;
            }
            $str=strval($year+$addYears)."-".strval($addMonths+$month)."-".$day." ".date("H:i:s",$this->_time);
            return new DateTime(strtotime($str));
        }else{
            $months=abs($months);
            $addYears=floor($months/12);
            $addMonths=$months%12;
            while($month-$addMonths<=0){
                $addYears++;
                $addMonths-=12;
            }
            $str=strval($year-$addYears)."-".strval($month-$addMonths)."-01";
            $lastDay = date("t",strtotime($str));//当月的最后一天
            if($day>$lastDay){
                $day=$lastDay;
            }
            $str=strval($year-$addYears)."-".strval($month-$addMonths)."-".$day." ".date("H:i:s",$this->_time);
            return new DateTime(strtotime($str));
        }
    }
534115
public function withDateAtEndOfMonth() : self
    {
        $instance = $this->withDateAtStartOfMonth();
        
        $instance->date->modify('+1 month');
        $instance->date->modify('-1 day');
        
        return $instance;
    }
42659
public static function numberOfDaysInMonth($month = 0, $year = 0)
    {
        if ($month < 1 or $month > 12) {
            return 0;
        }

        if (!is_numeric($year) or strlen($year) != 4) {
            $year = date('Y');
        }

        if ($month == 2) {
            if ($year % 400 == 0 or ($year % 4 == 0 and $year % 100 != 0)) {
                return 29;
            }
        }

        $days_in_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

        return $days_in_month[$month - 1];
    }
1356391
public function withDay(int $day) : MonthDay
    {
        if ($day === $this->day) {
            return $this;
        }

        Field\DayOfMonth::check($day, $this->month);

        return new MonthDay($this->month, $day);
    }
611835
public function setExpiryDateFromYearAndMonth($year, $month)
    {
        if (!in_array((string) $month, array(
            '01', '02', '03', '04',
            '05', '06', '07', '08',
            '09', '10', '11', '12',
        ))) {
            throw new \InvalidArgumentException('Invalid month '.$month);
        }

        $day = date('t', strtotime($year.'-'.$month.'-01'));

        $this->setExpiryDate(new \DateTime($year.'-'.$month.'-'.$day));

        return $this;
    }
934503
public function setByMonth($month)
    {
        if (!is_integer($month) || $month <= 0 || $month > 12) {
            throw new InvalidArgumentException('Invalid value for BYMONTH');
        }

        $this->byMonth = $month;

        $this->canUseBySetPos = true;

        return $this;
    }
732819
public function plusMonths(int $months) : LocalDateTime
    {
        if ($months === 0) {
            return $this;
        }

        return new LocalDateTime($this->date->plusMonths($months), $this->time);
    }
571804
public function plusMonths(int $months) : LocalDate
    {
        $month = $this->month + $months - 1;

        $yearDiff = Math::floorDiv($month, 12);
        $month = Math::floorMod($month, 12) + 1;

        $year = $this->year + $yearDiff;

        return $this->resolvePreviousValid($year, $month, $this->day);
    }
342237
public function perMonths(int $months, $task): ScheduleEvent
    {
        return $this->cron(sprintf('0 0 1 */%d *', $months), $task);
    }
1053599
public function plusYears(int $years) : YearMonth
    {
        if ($years === 0) {
            return $this;
        }

        return $this->withYear($this->year + $years);
    }