@param int $years

@return Period
334708
public function plusYears(int $years) : Period
    {
        if ($years === 0) {
            return $this;
        }

        return new Period($this->years + $years, $this->months, $this->days);
    }
22991
public function plusWeeks(int $weeks) : YearWeek
    {
        if ($weeks === 0) {
            return $this;
        }

        $mondayOfWeek = $this->atDay(DayOfWeek::MONDAY)->plusWeeks($weeks);

        return $mondayOfWeek->getYearWeek();
    }
230529
protected function extractYear(string $year): int
    {
        if (preg_match('/^(\d\d\d\d)\/\d{1,4}$/', $year, $match)) {
            // Assume the first year is correct
            $this->new_old_style = true;

            return (int) $match[1] + 1;
        }

        if (preg_match('/^(\d+) B\.C\.$/', $year, $match)) {
            return - (int) $match[1];
        }

        return (int) $year;
    }
598394
public static function prevPeriod($period, $year, $number)
    {
        if ($number > 1) {
            return array('year' => $year, 'number' => ($number - 1));
        } else {
            $maxPeriod = 12 / $period;

            return array('year' => ($year - 1), 'number' => $maxPeriod);
        }
    }
1315534
public static function getDaysInYear($year = null): int
    {
        $year = $year ? $year : date('Y');
        return self::isLeapYear($year) ? 366 : 365;
    }
574065
public function withYear(int $year) : YearWeek
    {
        if ($year === $this->year) {
            return $this;
        }

        Field\Year::check($year);

        $week = $this->week;

        if ($week === 53 && ! Field\WeekOfYear::is53WeekYear($year)) {
            $week = 52;
        }

        return new YearWeek($year, $week);
    }
489851
public function nthPreviousPeriod($n = 0)
    {
        $n = max(0, $n);

        // determine the interval string
        $interval = $this->interval($this->granularity());

        // calculate the start of the current period
        $start = $this->startOfDay(strtotime('this '.$interval));

        // go back N periods
        $i = $n;
        while ($i > 0) {
            $start = $this->startOfDay(strtotime('-1 '.$interval, $start));
            --$i;
        }

        // the end will be the start + 1 period - 1 second
        $end = $this->endOfDay(strtotime('+1 '.$interval, $start) - 1);

        return [
            'start' => $start,
            'end' => $end, ];
    }
541618
public function getPeriod($date)
    {
        $resultPeriod = null;

        for ($i = count($this->periods) - 1; $i >= 0; $i--) {
            $period = $this->periods[$i];

            if ($period->getEffectiveFrom() <= $date) {
                $resultPeriod = $period;
            }
        }

        return $resultPeriod;
    }
676845
public static function isLeapYear($year)
    {
        if (preg_match('/\D/', $year)) {
            return false;
        }
        if ($year < 1000) {
            return false;
        }
        if ($year < 1582) {
            // pre Gregorio XIII - 1582
            return ($year % 4 == 0);
        } else {
            // post Gregorio XIII - 1582
            return (($year % 4 == 0) && ($year % 100 != 0)) || ($year % 400 == 0);
        }
    }
554540
protected function getYears()
    {
        $intSecondsPerYear = ($this->isPositive()) ? DateTimeSpan::SECONDS_PER_YEAR : ((-1) * DateTimeSpan::SECONDS_PER_YEAR);
        $intYears = floor($this->intSeconds / $intSecondsPerYear);
        if ($this->isNegative()) {
            $intYears = (-1) * $intYears;
        }
        return $intYears;
    }
1289405
public static function of(int $year, int $week) : YearWeek
    {
        Field\Year::check($year);
        Field\WeekOfYear::check($week, $year);

        return new YearWeek($year, $week);
    }
272447
public static function cc_exp_years(int $length=10) {
		if ($length < 1) {
			$length = 10;
		}

		$years = array();
		for ($x = 0; $x < $length; ++$x) {
			$year = (int) (\date('Y') + $x);
			$years[$year] = $year;
		}

		return $years;
	}
567680
public CalendarYear minus(Years<CalendarUnit> years) {

        if (years.isEmpty()) {
            return this;
        }

        return CalendarYear.of(MathUtils.safeSubtract(this.year, years.getAmount()));

    }
1278574
public function subtractMonths($months)
    {
        $months = (int) $months;
        $months = -$months;
        return $this->addMonths($months);
    }
374154
public function byOrganizationWithYear($id)
  {
    // return $this->Period->where('organization_id', '=', $id)->with('year')->get(); -> Evitar los with

    $periods = $this->DB->connection($this->databaseConnectionName)
      ->table('ACCT_Period As p')
      ->join('ACCT_Fiscal_Year AS f', 'f.id', '=', 'p.fiscal_year_id')
      ->where('p.organization_id', '=', $id)
      ->get(array('p.id', 'p.month', 'f.year'));

    return new Collection($periods);
  }
351534
public CalendarWeek plus(Years<Weekcycle> years) {

        if (years.isEmpty()) {
            return this;
        }

        int y = MathUtils.safeAdd(this.year, years.getAmount());
        int effectiveWeek = this.week;

        if ((this.week == 53) && (maximumOfWeek(y) < 53)) {
            effectiveWeek = 52;
        }

        return CalendarWeek.of(y, effectiveWeek);

    }
890361
private static Period create(int years, int months, int days) {
        if ((years | months | days) == 0) {
            return ZERO;
        }
        return new Period(years, months, days);
    }