Validate a year.

@param int $year

@throws \InvalidArgumentException If year is not a valid int

@return int
15963
private static function validateYear($year)
	    {
	        $year = filter_var($year, FILTER_VALIDATE_INT);
	        if (false === $year) {
	            throw new InvalidArgumentException("A Year must be a valid int");
	        }

	        return $year;
	    }
1243016
protected function getYearly() {
        if (!$this->_yearly) {
            $this->_yearly = new YearlyList($this->version, $this->solution['accountSid']);
        }

        return $this->_yearly;
    }
57454
public function getYear()
    {
        if ($this->year === null) {
            $match = [];
            preg_match(self::$REGEX_YEAR, $this->output, $match);
            $this->year = (int)(array_key_exists(2, $match) ? $match[2] : 0);
        }

        return $this->year;
    }
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;
    }
1214109
public static function isLeapYear($year = null): bool
    {
        $year = $year ? $year : date('Y');
        return ($year % 4 == 0 && $year % 100 != 0 || $year % 400 == 0);
    }
1270767
protected static function isArithmeticLeapYear($year, $yearIsInGeorgian = false) {
        
        // a change for fit
        if ( ! $yearIsInGeorgian) {
            $year += static::HEGIRA_STARTING_YEAR;
        }
        
        $yearPositionInQuadCycle = static::calculateYearInQuadCycle($year) - 1;
        
        $arithmeticBreakPoints = [
            29,
            62,     // (29 + 33)
            95,     // (29 + 33 + 33)
            128,    // (29 + 33 + 33 + 33)
        ];
        
        foreach ($arithmeticBreakPoints as $i => $break) {
            if (isset($arithmeticBreakPoints[$i + 1])) {
                $nextBreak = $arithmeticBreakPoints[$i + 1];
                if ($yearPositionInQuadCycle >= $break && $yearPositionInQuadCycle < $nextBreak) {
                    $yearPositionInQuadCycle -= $break;
                    break;
                }
            }
        }
        
        // the first year is always a common year
        // other years whose ordinal numbers are divisible by 4 are leap years
        $isLeapYear = false;
        if ($yearPositionInQuadCycle != 0 && ($yearPositionInQuadCycle % 4) == 0) {
            $isLeapYear = true;
        }
        
        return $isLeapYear;
    }
192971
public static function toInt($value)
    {
        if (!static::is($value)) {
            throw new \InvalidArgumentException(
                "The \$value parameter must be numeric (or string representing a big number)."
            );
        }

        if (is_int($value)) {
            return $value;
        } elseif (is_float($value)) {
            return (int)$value;
        }

        if (($decimal = Str::pos($value, '.')) !== false) {
            $value = Str::sub($value, 0, (int)$decimal);
        }

        return $value;
    }
1275055
public final function setYear( int $year = null )
      : DateTime
   {

      if ( \is_null( $year ) )
      {
         $year = static::CurrentYear();
      }

      return $this->setDateParts( $year );

   }
1195173
public function daysInMonth($year, $month)
    {
        if ($year <= 0) {
            throw new InvalidArgumentException('Year ' . $year . ' is invalid for this calendar');
        } elseif ($month < 1 || $month > 13) {
            throw new InvalidArgumentException('Month ' . $month . ' is invalid for this calendar');
        } elseif ($month !== 13) {
            return 30;
        } elseif ($this->isLeapYear($year)) {
            return 6;
        } else {
            return 5;
        }
    }
722357
function(years) {
			years = years.split('.');
			if (years.length < 3) {
				throw 'Invalid Mayan year';
			}
			var year = 0;
			for (var i = 0; i < years.length; i++) {
				var y = parseInt(years[i], 10);
				if (Math.abs(y) > 19 || (i > 0 && y < 0)) {
					throw 'Invalid Mayan year';
				}
				year = year * 20 + y;
			}
			return year;
		}
1294271
function(year) {
			var date = this._validate(year, this.minMonth, this.minDay, $.calendars.local.invalidYear);
			year = date.year();
			var baktun = Math.floor(year / 400);
			year = year % 400;
			year += (year < 0 ? 400 : 0);
			var katun = Math.floor(year / 20);
			return baktun + '.' + katun + '.' + (year % 20);
		}
1205216
public function daysInMonth($year, $month)
    {
        if ($year < 1) {
            throw new InvalidArgumentException('Year ' . $year . ' is invalid for this calendar');
        } elseif ($month < 1 || $month > 13) {
            throw new InvalidArgumentException('Month ' . $month . ' is invalid for this calendar');
        } elseif ($month == 2) {
            return $this->daysInMonthHeshvan($year);
        } elseif ($month == 3) {
            return $this->daysInMonthKislev($year);
        } elseif ($month == 6) {
            return $this->daysInMonthAdarI($year);
        } else {
            return self::$FIXED_MONTH_LENGTHS[$month];
        }
    }
11000
public function year($value = null)
    {
        if ($value !== null) {
            if ($value < 0 || $value > 9999) {
                $this->year = 0;
            } else {
                $this->year = $value;
            }
        }
        return $this->year;
    }
701208
public function getYear(): Period
    {
        $year = (int) $this->format('Y');
        $datepoint = $this->setTime(0, 0);

        return new Period($datepoint->setDate($year, 1, 1), $datepoint->setDate(++$year, 1, 1));
    }
423976
private static function calculateYearInGrandCycle($year) {
        
        $grandCycle = static::calculateGrandCycle($year);
        
        if ($grandCycle < 0) {
            
            $year = (static::GRAND_CYCLE_BEGINNING + ($grandCycle * static::GRAND_CYCLE_LENGTH)) - $year;
            
        } elseif ($grandCycle > 0) {
            
            $year = $year - (static::GRAND_CYCLE_BEGINNING + ($grandCycle * static::GRAND_CYCLE_LENGTH));
            
        } else {
            
            $year -= static::GRAND_CYCLE_BEGINNING;
        }
        
        $yearInGrandCycle = abs($year) + 1;
        
        return $yearInGrandCycle;
    }
101299
public static function check(int $weekOfYear, int $year = null) : void
    {
        if ($weekOfYear < 1 || $weekOfYear > 53) {
            throw DateTimeException::fieldNotInRange(self::NAME, $weekOfYear, 1, 53);
        }

        if ($weekOfYear === 53 && $year !== null && ! self::is53WeekYear($year)) {
            throw new DateTimeException("Year $year does not have 53 weeks");
        }
    }
1291255
def year=(value)
      value = 0 if value.nil?

      if value.is_a?(String) 
        if value.length == 0
          value = 0
        elsif value =~ /\A\-?\d{1,7}\z/
          value = value.to_i
        else
          raise YearError, "Year must be a valid string or integer from -1048576 to 1048576"
        end
      end

      if (value >= -1048576 && value <= 1048576) 
        @bits = self.class.set_year(@bits, value)
      else
        raise YearError, "Year must be an integer from -1048576 to 1048576"
      end
    end