Civil Date PHP Package

YearNumbering
in package

FinalYes

Converts between calendar and astronomical year numbering.

Calendar years have no year zero. Astronomical years use zero for 1 BCE.

Table of Contents

Methods

expandTwoDigitYear()  : int
Expands a two-digit year to the nearest matching year around a reference year.
offsetYear()  : int
Offsets a calendar year by a given number of years, skipping year zero.
toAstronomicalYear()  : int
Converts a calendar year to astronomical year numbering.
toCalendarYear()  : int
Converts an astronomical year to a calendar year.

Methods

expandTwoDigitYear()

Expands a two-digit year to the nearest matching year around a reference year.

public static expandTwoDigitYear(int $year, int $referenceYear) : int
Parameters
$year : int

Two-digit year in the range 0..99.

$referenceYear : int

Full year used to choose the nearest matching year.

Tags
throws
InvalidArgumentException

If year is not in the range 0..99.

InvalidArgumentException

If reference year is zero.

Return values
int —

Expanded calendar year.

offsetYear()

Offsets a calendar year by a given number of years, skipping year zero.

public static offsetYear(int $year, int $offset) : int
Parameters
$year : int

Calendar year to offset.

$offset : int

Number of years to offset, positive or negative.

Tags
throws
InvalidArgumentException

If the input year is zero.

Return values
int —

Offset calendar year.

toAstronomicalYear()

Converts a calendar year to astronomical year numbering.

public static toAstronomicalYear(int $year) : int
Parameters
$year : int

Calendar year.

Tags
throws
InvalidArgumentException

If the input year is zero.

Return values
int —

Astronomical year.

toCalendarYear()

Converts an astronomical year to a calendar year.

public static toCalendarYear(int $year) : int
Parameters
$year : int

Astronomical year.

Return values
int —

Calendar year.

On this page

Search results