Civil Date PHP Package

CalendarSystem
in package

AbstractYes

Defines validation, conversion, and calendar-length behavior for a calendar system.

Tags
see
Calendar::system()
CalendarDate::calendarSystem()

Table of Contents

Methods

assertValidDay()  : void
Validates a calendar day.
assertValidMonth()  : void
Validates a calendar month.
assertValidYear()  : void
Validates a calendar year.
daysInMonth()  : int
Returns the number of days in a month.
daysInYear()  : int
Returns the number of days in a year.
id()  : Calendar
Returns the calendar identifier represented by this system.
instance()  : static
Returns the shared instance for the concrete calendar system.
isLeapYear()  : bool
Returns whether a year is leap according to this calendar.
isValidDay()  : bool
Determines whether a day number is valid for a calendar month.
isValidMonth()  : bool
Determines whether a month number is valid for a calendar year.
isValidYear()  : bool
Determines whether a year number is valid for this calendar.
monthsInYear()  : int
Returns the number of months in a year.
toDayOfYear()  : int
Converts calendar date components to a day of year value.
todayTimeZone()  : DateTimeZone|null
Returns the timezone used to resolve today's date.
toJDN()  : int
Converts calendar date components to a Julian Day Number.
toMonthDay()  : array{0: int, 1: int}
Converts a day of year value to calendar month and day components.
toYearMonthDay()  : array{0: int, 1: int, 2: int}
Converts a Julian Day Number to calendar year, month, and day components.
findYear()  : int
Finds the calendar year corresponding to a Julian Day Number.
firstDayOfYearJDN()  : int
Returns the Julian Day Number of the first day of a calendar year.

Methods

assertValidDay()

Validates a calendar day.

public final assertValidDay(int $year, int $month, int $day) : void
Parameters
$year : int

Calendar year.

$month : int

Calendar month number.

$day : int

Calendar day of month.

Tags
throws
InvalidArgumentException

If the date components are invalid.

assertValidMonth()

Validates a calendar month.

public final assertValidMonth(int $year, int $month) : void
Parameters
$year : int

Calendar year.

$month : int

Calendar month number.

Tags
throws
InvalidArgumentException

If the year or month is invalid.

assertValidYear()

Validates a calendar year.

public assertValidYear(int $year) : void
Parameters
$year : int

Calendar year.

Tags
throws
InvalidArgumentException

If the year is invalid.

daysInMonth()

Returns the number of days in a month.

public abstract daysInMonth(int $year, int $month) : int
Parameters
$year : int

Calendar year.

$month : int

Calendar month number.

Tags
throws
InvalidArgumentException

If the year or month is invalid.

Return values
int —

Number of days in the month.

daysInYear()

Returns the number of days in a year.

public abstract daysInYear(int $year) : int
Parameters
$year : int

Calendar year.

Tags
throws
InvalidArgumentException

If the year is invalid.

Return values
int —

Number of days in the year.

instance()

Returns the shared instance for the concrete calendar system.

public final static instance() : static
Tags
see
Calendar::system()
Return values
static —

Calendar system instance.

isLeapYear()

Returns whether a year is leap according to this calendar.

public abstract isLeapYear(int $year) : bool
Parameters
$year : int

Calendar year.

Tags
throws
InvalidArgumentException

If the year is invalid.

Return values
bool —

True when the year is leap.

isValidDay()

Determines whether a day number is valid for a calendar month.

public isValidDay(int $year, int $month, int $day) : bool
Parameters
$year : int

Calendar year.

$month : int

Calendar month number.

$day : int

Calendar day of month.

Return values
bool —

True when the day is valid, false otherwise.

isValidMonth()

Determines whether a month number is valid for a calendar year.

public isValidMonth(int $year, int $month) : bool
Parameters
$year : int

Calendar year.

$month : int

Calendar month number.

Return values
bool —

True when the month is valid, false otherwise.

isValidYear()

Determines whether a year number is valid for this calendar.

public isValidYear(int $year) : bool
Parameters
$year : int

Calendar year.

Return values
bool —

True when the year is valid, false otherwise.

monthsInYear()

Returns the number of months in a year.

public monthsInYear(int $year) : int
Parameters
$year : int

Calendar year.

Tags
throws
InvalidArgumentException

If the year is invalid.

Return values
int —

Number of months in the year.

toDayOfYear()

Converts calendar date components to a day of year value.

public toDayOfYear(int $year, int $month, int $day) : int
Parameters
$year : int

Calendar year.

$month : int

Calendar month number.

$day : int

Calendar day of month.

Tags
throws
InvalidArgumentException

If the date components are invalid.

Return values
int —

Day of year, where 1 is the first day of the year.

todayTimeZone()

Returns the timezone used to resolve today's date.

public todayTimeZone() : DateTimeZone|null
Return values
DateTimeZone|null —

Timezone for today, or null for the default timezone.

toJDN()

Converts calendar date components to a Julian Day Number.

public toJDN(int $year, int $month, int $day) : int
Parameters
$year : int

Calendar year.

$month : int

Calendar month number.

$day : int

Calendar day of month.

Tags
throws
InvalidArgumentException

If the date components are invalid.

see
CalendarSystem::toYearMonthDay()
CalendarDate::jdn()
Return values
int —

Julian Day Number.

toMonthDay()

Converts a day of year value to calendar month and day components.

public toMonthDay(int $year, int $dayOfYear) : array{0: int, 1: int}
Parameters
$year : int

Calendar year.

$dayOfYear : int

Day of year, where 1 is the first day of the year.

Tags
throws
InvalidArgumentException

If the year or day of year is invalid.

Return values
array{0: int, 1: int} —

Calendar [month, day] components.

toYearMonthDay()

Converts a Julian Day Number to calendar year, month, and day components.

public toYearMonthDay(int $jdn) : array{0: int, 1: int, 2: int}
Parameters
$jdn : int

Julian Day Number.

Tags
throws
DateOutOfRangeException

If the Julian Day Number cannot be converted to a valid calendar date.

see
CalendarSystem::toJDN()
CalendarDate::fromJDN()
Return values
array{0: int, 1: int, 2: int} —

Calendar [year, month, day] components.

findYear()

Finds the calendar year corresponding to a Julian Day Number.

protected abstract findYear(int $jdn) : int
Parameters
$jdn : int

Julian Day Number.

Return values
int —

Calendar year corresponding to the Julian Day Number, or zero if the year cannot be determined.

firstDayOfYearJDN()

Returns the Julian Day Number of the first day of a calendar year.

protected abstract firstDayOfYearJDN(int $year) : int
Parameters
$year : int

Calendar year.

Return values
int —

Julian Day Number of the first day of the year.

On this page

Search results