Returns a <code>Calendar</code> object for the current or a given year.

@param  int  $year  The current year if omitted.
@return Calendar
19927
public static function year($year = null)
	{
		$from = DateTime::create(1, 1, $year);
		$till = $from->copy()->addYears(1)->addDays(-1);
		return new Calendar($from, $till);
	}
649011
public static function FirstDayInYearCarbon(int $year)
    {
        return \Carbon\Carbon::parse( \Phunc\Year::FirstDayInYear($year) );
    }
237806
public CalendarMonth minus(Years<CalendarUnit> years) {

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

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

    }
1128393
public function withWeek(int $week) : YearWeek
    {
        if ($week === $this->week) {
            return $this;
        }

        Field\WeekOfYear::check($week);

        $year = $this->year;

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

        return new YearWeek($year, $week);
    }
1194738
public static function firstDayOfYear($year = null, $format = 'Y-m-d')
    {
        $year = $year ? $year : date('Y');
        return date($format, mktime(0, 0, 0, 1, 1, $year));
    }
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;
	    }
1278328
public function year($value) {
        
        $this->setDate($value, $this->month, $this->day);
        
        return $this;
    }
1347182
public function getMonths($year)
    {
        $year = $this->yearOrYearNo($year);

        $months = array();

        for ($monthNo = 1; $monthNo <= 12; $monthNo++) {
            $months[$monthNo] = new Month($year, $monthNo);
        }

        return $months;
    }
1200088
private function yearType($year)
    {
        $year_length = $this->yToJd($year + 1) - $this->yToJd($year);

        if ($year_length === 353 || $year_length === 383) {
            return self::DEFECTIVE_YEAR;
        } elseif ($year_length === 355 || $year_length === 385) {
            return self::COMPLETE_YEAR;
        } else {
            return self::REGULAR_YEAR;
        }
    }
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;
    }
1305615
public static function createDate($year = null, $month = null, $day = null, $timezone = null)
    {
        return static::create($year, $month, $day, null, null, null, $timezone);
    }
942615
public function getCalendar() : ?string 
    {
        if ( ! $this->hasCalendar()) {
            $this->setCalendar($this->getDefaultCalendar());
        }
        return $this->calendar;
    }
1250470
public function year()
    {
        if (!isset($this->year)) {
            $this->year = new Year($this->startDateTime->format('Y'));
        }
        return $this->year;
    }
446571
public function getHolidaysByYear($year)
    {
        $easter = $this->getEasterDates($year);

        $midSummerDay = $this->getMidSummerDay($year);

        $allSaintsDay = $this->getAllSaintsDay($year);

        return array(
            '01-01' => $this->createData('Nyårsdagen'),
            '01-05' => $this->createData('Trettondagsafton', array('halfday' => true)),
            '01-06' => $this->createData('Trettondedag jul'),
            '04-30' => $this->createData('Valborgsmässoafton', array('halfday' => true)),
            '05-01' => $this->createData('Första maj'),
            '06-06' => $this->createData('Sveriges nationaldag'),
            '12-24' => $this->createData('Julafton'),
            '12-25' => $this->createData('Juldagen'),
            '12-26' => $this->createData('Annandag jul'),
            '12-31' => $this->createData('Nyårsafton'),
            // Variable dates
            $easter['maundyThursday']->format(self::DATE_FORMAT) => $this->createData('Skärtorsdagen', array('halfday' => true)),
            $easter['goodFriday']->format(self::DATE_FORMAT) => $this->createData('Långfredagen'),
            $easter['saturday']->format(self::DATE_FORMAT) => $this->createData('Påskafton'),
            $easter['easterSunday']->format(self::DATE_FORMAT) => $this->createData('Påskdagen'),
            $easter['easterMonday']->format(self::DATE_FORMAT) => $this->createData('Annandag påsk'),
            $easter['ascensionDay']->format(self::DATE_FORMAT) => $this->createData('Kristi himmelsfärdsdag'),
            $easter['pentecostSaturday']->format(self::DATE_FORMAT) => $this->createData('Pingstafton'),
            $easter['pentecostSunday']->format(self::DATE_FORMAT) => $this->createData('Pingstdagen'),

            $midSummerDay->format(self::DATE_FORMAT) => $this->createData('Midsommardagen'),
            $midSummerDay->modify('-1 day')->format(self::DATE_FORMAT) => $this->createData('Midsommarafton'),

            $allSaintsDay->format(self::DATE_FORMAT) => $this->createData('Alla helgons dag'),
            $allSaintsDay->modify('-1 day')->format(self::DATE_FORMAT) => $this->createData('Allhelgonaafton', array('halfday' => true))
        );
    }
1132430
public static function create(int $year, int $month, int $day): Date
    {
        return new static($year, $month, $day);
    }
398189
public function generateObject($current)
	{
		$nodeCalendar = XmlUtil::CreateChild($current, "calendar", "");
				
		XmlUtil::AddAttribute($nodeCalendar, "name", "cal" . (rand(1000, 9999)) );
		XmlUtil::AddAttribute($nodeCalendar, "month", $this->_month);
		XmlUtil::AddAttribute($nodeCalendar, "year", $this->_year);
		XmlUtil::AddAttribute($nodeCalendar, "title", $this->_title);
		
		foreach($this->_events as $key=>$calendarEvent)
		{
			$calendarEvent->generateObject($nodeCalendar);
		}
	}
334708
public function plusYears(int $years) : Period
    {
        if ($years === 0) {
            return $this;
        }

        return new Period($this->years + $years, $this->months, $this->days);
    }