JalaliDate
extends CalendarDate
in package
Represents an immutable date in the Jalali calendar system.
Table of Contents
Constants
- MAX_YEAR : int = \Kampute\CivilDate\Calendars\JalaliCalendar::MA...
- Maximum supported Jalali year.
- MIN_YEAR : int = \Kampute\CivilDate\Calendars\JalaliCalendar::MI...
- Minimum supported Jalali year.
Properties
- $calendar : Calendar
- $calendarSystem : CalendarSystem
- $day : int
- $dayOfWeek : DayOfWeek
- $dayOfWeekInMonth : int
- $dayOfWeekInYear : int
- $dayOfYear : int
- $daysInMonth : int
- $daysInYear : int
- $isLeapYear : bool
- $jdn : int
- $month : int
- $monthsInYear : int
- $quarter : int
- $season : Season
- $year : int
Methods
- __construct() : mixed
- Creates a date from calendar components.
- __get() : mixed
- Returns the value of a read-only calendar property.
- __serialize() : array{jdn: int}
- Returns the PHP serialization representation of this date.
- __toString() : string
- Returns the date as a string.
- __unserialize() : void
- Restores this date from its PHP serialization representation.
- addDays() : static
- Returns a new date offset by a number of days.
- addMonths() : static
- Returns a new date offset by a number of calendar months.
- addYears() : static
- Returns a new date offset by a number of calendar years.
- calendar() : Calendar
- Returns the calendar identifier used by this date class.
- calendarSystem() : JalaliCalendar
- Returns the Jalali calendar system.
- compareTo() : int
- Compares this date to another calendar date by chronological order.
- day() : int
- Returns the calendar day-of-month component.
- dayOfWeek() : DayOfWeek
- Returns this date's day of week.
- dayOfWeekInMonth() : int
- Returns this date's one-based occurrence of its day of week within the calendar month.
- dayOfWeekInYear() : int
- Returns this date's one-based occurrence of its day of week within the calendar year.
- dayOfYear() : int
- Returns this date's one-based day of year.
- daysInMonth() : int
- Returns the number of days in this date's month.
- daysInYear() : int
- Returns the number of days in this date's year.
- daysOfWeekInMonth() : int
- Returns the number of times a day of week occurs within this date's month.
- daysOfWeekInYear() : int
- Returns the number of times a day of week occurs within this date's year.
- differenceInDays() : int
- Returns the signed day difference from this date to another date.
- differenceInMonths() : int
- Returns the signed month difference from this date to another date, ignoring any day-of-month differences.
- differenceInYears() : int
- Returns the signed year difference from this date to another date, ignoring any month or day differences.
- endOfMonth() : static
- Returns the last day of this date's month.
- endOfQuarter() : static
- Returns the last day of this date's quarter.
- endOfWeek() : static
- Returns the final day of this date's week.
- endOfYear() : static
- Returns the last day of this date's year.
- equals() : bool
- Returns whether this date and another date represent the same civil day.
- format() : string
- Formats this date with a calendar format pattern.
- fromDateTime() : static
- Creates a date from a DateTimeInterface value using its own timezone.
- fromDayOfMonth() : static
- Creates a date from a relative day of month.
- fromDayOfYear() : static
- Creates a date from a relative day of year.
- fromGregorianDate() : static
- Creates a date from a Gregorian calendar date.
- fromIso8601DateString() : static
- Creates a date from a Gregorian ISO 8601 date string.
- fromJDN() : static
- Creates a date from a Julian Day Number.
- fromNthDayOfWeekInMonth() : static
- Creates a date from an occurrence of a day of week in a calendar month.
- fromNthDayOfWeekInYear() : static
- Creates a date from an occurrence of a day of week in a calendar year.
- getTestToday() : static|null
- Returns the configured date for today() in this calendar.
- isAfter() : bool
- Returns whether this date is after another date chronologically.
- isBefore() : bool
- Returns whether this date is before another date chronologically.
- isBetween() : bool
- Returns whether this date is inside an inclusive date range defined by two other dates.
- isLeapYear() : bool
- Returns whether this date's year is a leap year for its calendar.
- isSameDay() : bool
- Returns whether this date and another date are in the same calendar day.
- isSameMonth() : bool
- Returns whether this date and another date are in the same calendar month.
- isSameQuarter() : bool
- Returns whether this date and another date are in the same calendar quarter.
- isSameSeason() : bool
- Returns whether this date and another date are in the same calendar season.
- isSameWeek() : bool
- Returns whether this date and another date are in the same calendar week.
- isSameYear() : bool
- Returns whether this date and another date are in the same calendar year.
- jdn() : int
- Returns this date's Julian Day Number.
- month() : int
- Returns the calendar month component.
- monthsInYear() : int
- Returns the number of months in this date's year.
- nextDayOfWeek() : static
- Returns the next occurrence of a day of week after this date.
- parse() : static
- Parses a date string using a format pattern.
- previousDayOfWeek() : static
- Returns the previous occurrence of a day of week before this date.
- quarter() : int
- Returns this date's quarter of the year.
- season() : Season
- Returns this Jalali date's Iran/northern-hemisphere season.
- setTestToday() : void
- Sets the date returned by today().
- startOfMonth() : static
- Returns the first day of this date's month.
- startOfQuarter() : static
- Returns the first day of this date's quarter.
- startOfWeek() : static
- Returns the first day of this date's week.
- startOfYear() : static
- Returns the first day of this date's year.
- toArray() : array{0: int, 1: int, 2: int}
- Returns the calendar components of this date as an array in [year, month, day] order.
- toCalendar() : self
- Returns this civil day represented in the requested calendar system.
- today() : static
- Returns today's date in this calendar.
- toIso8601DateString() : string
- Returns this date as a Gregorian ISO 8601 date string.
- tomorrow() : static
- Returns tomorrow's date in this calendar.
- weeksInMonth() : int
- Returns the number of weeks spanned by this date's month.
- weeksInYear() : int
- Returns the number of weeks spanned by this date's year.
- withDay() : static
- Returns a new date with a different day of month.
- withMonth() : static
- Returns a new date with a different month.
- withYear() : static
- Returns a new date with a different year.
- year() : int
- Returns the calendar year component.
- yesterday() : static
- Returns yesterday's date in this calendar.
- dateFromParsedFields() : static|null
- Creates a date from parsed field values for the called calendar.
- normalizeParseText() : string
- Normalizes parse input and pattern text.
- startOfMonthJDN() : int
- Returns the Julian Day Number of the first day of this date's month.
- startOfYearJDN() : int
- Returns the Julian Day Number of the first day of this date's year.
- toDayOfWeek() : DayOfWeek
- Validates a day of week value and returns a DayOfWeek instance.
- toLocale() : Locale
- Validates a locale value and returns a Locale instance.
- validateParsedFields() : void
- Validates parsed property values against this date.
Constants
MAX_YEAR
Maximum supported Jalali year.
public
int
MAX_YEAR
= \Kampute\CivilDate\Calendars\JalaliCalendar::MAX_YEAR
MIN_YEAR
Minimum supported Jalali year.
public
int
MIN_YEAR
= \Kampute\CivilDate\Calendars\JalaliCalendar::MIN_YEAR
Properties
$calendar read-only
public
Calendar
$calendar
Calendar identifier.
$calendarSystem read-only
public
CalendarSystem
$calendarSystem
Calendar system for this date.
$day read-only
public
int
$day
Jalali day of month.
$dayOfWeek read-only
public
DayOfWeek
$dayOfWeek
Day of the week of this date.
$dayOfWeekInMonth read-only
public
int
$dayOfWeekInMonth
Occurrence of this date's day of week within the month.
$dayOfWeekInYear read-only
public
int
$dayOfWeekInYear
Occurrence of this date's day of week within the year.
$dayOfYear read-only
public
int
$dayOfYear
Day of the year of this date, with Nowruz as day 1.
$daysInMonth read-only
public
int
$daysInMonth
Number of days in the month of this date.
$daysInYear read-only
public
int
$daysInYear
Number of days in the year of this date.
$isLeapYear read-only
public
bool
$isLeapYear
True if this date falls in a leap year, false otherwise.
$jdn read-only
public
int
$jdn
Julian Day Number of this date.
$month read-only
public
int
$month
Jalali month number.
$monthsInYear read-only
public
int
$monthsInYear
Number of months in the year.
$quarter read-only
public
int
$quarter
Jalali quarter of this date.
$season read-only
public
Season
$season
Iran/northern-hemisphere season for this date.
$year read-only
public
int
$year
Jalali year number.
Methods
__construct()
Creates a date from calendar components.
public
__construct(int $year, int $month, int $day) : mixed
Parameters
- $year : int
-
Calendar year.
- $month : int
-
Calendar month number.
- $day : int
-
Calendar day of month.
Tags
__get()
Returns the value of a read-only calendar property.
public
__get(string $name) : mixed
Parameters
- $name : string
-
Property name.
Tags
Return values
mixed —Property value.
__serialize()
Returns the PHP serialization representation of this date.
public
final __serialize() : array{jdn: int}
The Julian Day Number is used as the serialized state because it uniquely identifies the represented day independently of any calendar system.
Return values
array{jdn: int} —Serializable date state.
__toString()
Returns the date as a string.
public
__toString() : string
Return values
string —String representation of the date.
__unserialize()
Restores this date from its PHP serialization representation.
public
final __unserialize(array<string, mixed> $data) : void
The concrete date class determines which calendar components are rebuilt from the serialized Julian Day Number.
Parameters
- $data : array<string, mixed>
-
Serialized date state.
Tags
addDays()
Returns a new date offset by a number of days.
public
final addDays(int $days) : static
Parameters
- $days : int
-
Number of days to add, possibly negative.
Tags
Return values
static —Shifted date.
addMonths()
Returns a new date offset by a number of calendar months.
public
final addMonths(int $months) : static
If the target month has fewer days, the day of month is clamped to that month end.
Parameters
- $months : int
-
Number of months to add, possibly negative.
Tags
Return values
static —Shifted date, with day clamped if needed.
addYears()
Returns a new date offset by a number of calendar years.
public
final addYears(int $years) : static
If the target year does not contain the current month or day, the result is clamped to the nearest valid date in that year.
Parameters
- $years : int
-
Number of years to add, possibly negative.
Tags
Return values
static —Shifted date, with month or day clamped if needed.
calendar()
Returns the calendar identifier used by this date class.
public
final static calendar() : Calendar
Tags
Return values
Calendar —Calendar identifier.
calendarSystem()
Returns the Jalali calendar system.
public
static calendarSystem() : JalaliCalendar
Tags
Return values
JalaliCalendar —Jalali calendar system.
compareTo()
Compares this date to another calendar date by chronological order.
public
final compareTo(self $other) : int
Parameters
- $other : self
-
Date to compare.
Return values
int —Negative when this date is before $other, zero when equal, positive when after.
day()
Returns the calendar day-of-month component.
public
final day() : int
Return values
int —Calendar day of month.
dayOfWeek()
Returns this date's day of week.
public
final dayOfWeek() : DayOfWeek
Return values
DayOfWeek —Day-of-week enum value.
dayOfWeekInMonth()
Returns this date's one-based occurrence of its day of week within the calendar month.
public
final dayOfWeekInMonth() : int
Return values
int —Positive occurrence number from the start of the month.
dayOfWeekInYear()
Returns this date's one-based occurrence of its day of week within the calendar year.
public
final dayOfWeekInYear() : int
Return values
int —Positive occurrence number from the start of the year.
dayOfYear()
Returns this date's one-based day of year.
public
final dayOfYear() : int
Return values
int —Day of year.
daysInMonth()
Returns the number of days in this date's month.
public
final daysInMonth() : int
Return values
int —Number of days in the month.
daysInYear()
Returns the number of days in this date's year.
public
final daysInYear() : int
Return values
int —Number of days in the year.
daysOfWeekInMonth()
Returns the number of times a day of week occurs within this date's month.
public
final daysOfWeekInMonth(int|DayOfWeek $dayOfWeek) : int
Parameters
- $dayOfWeek : int|DayOfWeek
-
Day of week to count.
Tags
Return values
int —Count of matching days of week in the month.
daysOfWeekInYear()
Returns the number of times a day of week occurs within this date's year.
public
final daysOfWeekInYear(int|DayOfWeek $dayOfWeek) : int
Parameters
- $dayOfWeek : int|DayOfWeek
-
Day of week to count.
Tags
Return values
int —Count of matching days of week in the year.
differenceInDays()
Returns the signed day difference from this date to another date.
public
final differenceInDays(self $other) : int
Parameters
- $other : self
-
Target date.
Return values
int —Number of days.
differenceInMonths()
Returns the signed month difference from this date to another date, ignoring any day-of-month differences.
public
final differenceInMonths(self $other) : int
Parameters
- $other : self
-
Target date.
Return values
int —Number of months.
differenceInYears()
Returns the signed year difference from this date to another date, ignoring any month or day differences.
public
final differenceInYears(self $other) : int
Parameters
- $other : self
-
Target date.
Return values
int —Number of years.
endOfMonth()
Returns the last day of this date's month.
public
final endOfMonth() : static
Return values
static —Last day of month.
endOfQuarter()
Returns the last day of this date's quarter.
public
final endOfQuarter() : static
Return values
static —Last day of quarter.
endOfWeek()
Returns the final day of this date's week.
public
final endOfWeek(int|DayOfWeek $firstDayOfWeek) : static
Parameters
- $firstDayOfWeek : int|DayOfWeek
-
Day of week considered as the start of the week.
Tags
Return values
static —Date ending the week.
endOfYear()
Returns the last day of this date's year.
public
final endOfYear() : static
Return values
static —Last day of year.
equals()
Returns whether this date and another date represent the same civil day.
public
final equals(self $other) : bool
Dates in different calendars are equal when they identify the same day.
Parameters
- $other : self
-
Date to compare.
Return values
bool —True when equal.
format()
Formats this date with a calendar format pattern.
public
format(string $pattern[, Locale|string, protectTextDirection?: bool} $options = [] ]) : string
A pattern is a sequence of tokens and literal text. Tokens write date fields. Literal text is copied to the output. Single-quoted or double-quoted text is always literal text. A backslash escapes the next character.
A calendar scope writes a sub-pattern in another calendar. Scope syntax
is [Calendar:pattern], for example [Gregorian:Y-m-d]. Scope names
match Calendar case names case-insensitively. Scopes cannot be nested.
Unscoped tokens format fields from this date. Scoped tokens first convert the same civil day to the scoped calendar, then format that scoped date.
Supported tokens:
Y: year number with minimum 4 digits, padded with leading zeros.V: year in cardinal words.y: two-digit year.n: month number.m: month number with minimum 2 digits, padded with leading zeros.F: name of month.M: abbreviated name of month.j: day of month.d: day of month with minimum 2 digits, padded with leading zeros.J: day of month in ordinal words.l: name of day of week.D: abbreviated name of day of week.k: day of week occurrence in the month, as ordinal words.K: day of week occurrence in the year, as ordinal words.R: day of year in ordinal words.q: quarter in ordinal words.Q: season name.C: era name.E: abbreviated era name.
Formatting uses the selected locale for numbers, words, names, and text direction. When text-direction protection is enabled, the result is wrapped in Unicode isolate controls for the locale direction.
Parameters
- $pattern : string
-
Format pattern.
- $options : Locale|string, protectTextDirection?: bool} = []
-
Formatting options:
- locale: Locale or language tag used for numbers, words, names, and text direction (default LocaleRegistry::default()).
- protectTextDirection: Wrap the result in Unicode isolate controls for the locale direction (default false).
Tags
Return values
string —Formatted date.
fromDateTime()
Creates a date from a DateTimeInterface value using its own timezone.
public
final static fromDateTime(DateTimeInterface $dateTime) : static
Only the civil date part is used. The time of day is ignored after the value has been interpreted in its own timezone.
Parameters
- $dateTime : DateTimeInterface
-
Date and time whose civil date should be converted.
Tags
Return values
static —Equivalent date in this calendar.
fromDayOfMonth()
Creates a date from a relative day of month.
public
final static fromDayOfMonth(int $year, int $month, int $dayOfMonth) : static
Positive values count from the first day of the month. Negative values
count from the last day, so -1 selects the last day of the month.
Parameters
- $year : int
-
Calendar year.
- $month : int
-
Calendar month number.
- $dayOfMonth : int
-
The day of month, where positive values count from the start of the month and negative values count from the end of the month.
Tags
Return values
static —Calendar date represented by the day-of-month value.
fromDayOfYear()
Creates a date from a relative day of year.
public
final static fromDayOfYear(int $year, int $dayOfYear) : static
Positive values count from the first day of the year. Negative values
count from the last day, so -1 selects the last day of the year.
Parameters
- $year : int
-
Calendar year.
- $dayOfYear : int
-
The day of year, where positive values count from the start of the year and negative values count from the end of the year.
Tags
Return values
static —Calendar date represented by the day-of-year value.
fromGregorianDate()
Creates a date from a Gregorian calendar date.
public
final static fromGregorianDate(int $year, int $month, int $day) : static
This is useful when external input is Gregorian but the application works with another calendar.
Parameters
- $year : int
-
Gregorian calendar year.
- $month : int
-
Gregorian calendar month number.
- $day : int
-
Gregorian calendar day of month.
Tags
Return values
static —Equivalent date in this calendar.
fromIso8601DateString()
Creates a date from a Gregorian ISO 8601 date string.
public
final static fromIso8601DateString(string $isoDate) : static
The accepted shape is YYYY-MM-DD, with a signed year allowed when the
year has more than four digits.
Parameters
- $isoDate : string
-
Gregorian date in ISO 8601
YYYY-MM-DDform.
Tags
Return values
static —Equivalent date in this calendar.
fromJDN()
Creates a date from a Julian Day Number.
public
final static fromJDN(int $jdn) : static
The returned instance uses this class's calendar while representing the same civil day as the supplied Julian Day Number.
Parameters
- $jdn : int
-
Julian Day Number.
Tags
Return values
static —Calendar date corresponding to the Julian Day Number.
fromNthDayOfWeekInMonth()
Creates a date from an occurrence of a day of week in a calendar month.
public
final static fromNthDayOfWeekInMonth(int $year, int $month, int $occurrence, int|DayOfWeek $dayOfWeek) : static
Positive occurrences count from the start of the month. Negative occurrences count from the end of the month.
Parameters
- $year : int
-
Calendar year.
- $month : int
-
Calendar month number.
- $occurrence : int
-
The occurrence number of the day of week, where positive values count from the start of the month and negative values count from the end of the month.
- $dayOfWeek : int|DayOfWeek
-
Day of week as enum or compatible integer.
Tags
Return values
static —Date for the requested day of week occurrence inside the requested month.
fromNthDayOfWeekInYear()
Creates a date from an occurrence of a day of week in a calendar year.
public
final static fromNthDayOfWeekInYear(int $year, int $occurrence, int|DayOfWeek $dayOfWeek) : static
Positive occurrences count from the start of the year. Negative occurrences count from the end of the year.
Parameters
- $year : int
-
Calendar year.
- $occurrence : int
-
The occurrence number of the day of week, where positive values count from the start of the year and negative values count from the end of the year.
- $dayOfWeek : int|DayOfWeek
-
Day of week to select.
Tags
Return values
static —Date for the requested day of week occurrence inside the requested year.
getTestToday()
Returns the configured date for today() in this calendar.
public
final static getTestToday() : static|null
Tags
Return values
static|null —Configured date, or null when today() uses real time.
isAfter()
Returns whether this date is after another date chronologically.
public
final isAfter(self $other) : bool
Parameters
- $other : self
-
Date to compare.
Return values
bool —True when after.
isBefore()
Returns whether this date is before another date chronologically.
public
final isBefore(self $other) : bool
Parameters
- $other : self
-
Date to compare.
Return values
bool —True when before.
isBetween()
Returns whether this date is inside an inclusive date range defined by two other dates.
public
final isBetween(self $start, self $end) : bool
Parameters
- $start : self
-
Inclusive start.
- $end : self
-
Inclusive end.
Return values
bool —True when inside.
isLeapYear()
Returns whether this date's year is a leap year for its calendar.
public
final isLeapYear() : bool
Return values
bool —True when the date falls in a leap year.
isSameDay()
Returns whether this date and another date are in the same calendar day.
public
final isSameDay(self $other) : bool
Parameters
- $other : self
-
Date to compare.
Return values
bool —True when same day.
isSameMonth()
Returns whether this date and another date are in the same calendar month.
public
final isSameMonth(self $other) : bool
Parameters
- $other : self
-
Date to compare.
Return values
bool —True when same month.
isSameQuarter()
Returns whether this date and another date are in the same calendar quarter.
public
final isSameQuarter(self $other) : bool
Parameters
- $other : self
-
Date to compare.
Return values
bool —True when same quarter.
isSameSeason()
Returns whether this date and another date are in the same calendar season.
public
final isSameSeason(self $other) : bool
Seasons use the Iran/northern-hemisphere convention of spring starting at the March equinox, summer at the June solstice, autumn at the September equinox, and winter at the December solstice.
Parameters
- $other : self
-
Date to compare.
Return values
bool —True when same season.
isSameWeek()
Returns whether this date and another date are in the same calendar week.
public
final isSameWeek(self $other, int|DayOfWeek $firstDayOfWeek) : bool
Parameters
- $other : self
-
Date to compare.
- $firstDayOfWeek : int|DayOfWeek
-
Day of week considered as the start of the week.
Tags
Return values
bool —True when same week.
isSameYear()
Returns whether this date and another date are in the same calendar year.
public
final isSameYear(self $other) : bool
Parameters
- $other : self
-
Date to compare.
Return values
bool —True when same year.
jdn()
Returns this date's Julian Day Number.
public
final jdn() : int
Tags
Return values
int —Julian Day Number.
month()
Returns the calendar month component.
public
final month() : int
Return values
int —Calendar month number.
monthsInYear()
Returns the number of months in this date's year.
public
final monthsInYear() : int
Return values
int —Number of months in the year.
nextDayOfWeek()
Returns the next occurrence of a day of week after this date.
public
final nextDayOfWeek(int|DayOfWeek $dayOfWeek[, int $occurrence = 1 ]) : static
Parameters
- $dayOfWeek : int|DayOfWeek
-
Day of week to select.
- $occurrence : int = 1
-
One-based occurrence after this date.
Tags
Return values
static —Selected future date.
parse()
Parses a date string using a format pattern.
public
static parse(string $input, string $pattern[, Locale|string, preserveBidiControls?: bool, preserveWhitespace?: bool, skipValidation?: bool} $options = [] ]) : static
A pattern is a sequence of tokens and literal text. Tokens read date fields. Literal text must appear in the input at the same position. Single-quoted or double-quoted text is always literal text. A backslash escapes the next character.
A calendar scope reads a sub-pattern in another calendar. Scope syntax is
[Calendar:pattern], for example [Gregorian:Y-m-d]. Scope names
match Calendar case names case-insensitively. Scopes cannot be nested.
Unscoped tokens resolve the date returned by this class. Scoped tokens validate the same civil day in the scoped calendar; they do not change the returned date class.
Supported tokens:
Y: year number.V: year number, as digits or words.y: two-digit year.n: month number.m: month number.F: name of month.M: abbreviated name of month.j: day of month.d: day of month.J: day of month, as digits or words.l: name of day of week.D: abbreviated name of day of week.k: day of week occurrence in the month, as digits or words.K: day of week occurrence in the year, as digits or words.R: day of year, as digits or words.q: quarter, as digits or words.Q: season name.C: era name.E: abbreviated era name.
The primary calendar fields must identify one date. Accepted field sets:
- Year, month, and day.
- Year and day of year.
- Year, day of week occurrence in year, and day of week.
- Year, month, day of week occurrence in month, and day of week.
Parsing uses the selected locale for digits, number words, names, and text normalization. By default it strips Unicode bidi controls and normalizes whitespace in both input and pattern. Parsed day of week, day of year, ordinal position, quarter, season, era, and scoped calendar fields are checked against the resolved date unless validation is skipped.
Parameters
- $input : string
-
Input text to parse.
- $pattern : string
-
Format pattern.
- $options : Locale|string, preserveBidiControls?: bool, preserveWhitespace?: bool, skipValidation?: bool} = []
-
Parsing options:
- locale: Locale or language tag used for localized digits, words, names, and text normalization (default LocaleRegistry::default()).
- preserveBidiControls: Keep Unicode bidi control characters in the input and pattern (default false).
- preserveWhitespace: Match whitespace exactly instead of trimming and collapsing whitespace (default false).
- skipValidation: Skip consistency checks for derived and scoped fields after the date is resolved (default false).
Tags
Return values
static —Parsed date.
previousDayOfWeek()
Returns the previous occurrence of a day of week before this date.
public
final previousDayOfWeek(int|DayOfWeek $dayOfWeek[, int $occurrence = 1 ]) : static
Parameters
- $dayOfWeek : int|DayOfWeek
-
Day of week to select.
- $occurrence : int = 1
-
One-based occurrence before this date.
Tags
Return values
static —Selected past date.
quarter()
Returns this date's quarter of the year.
public
final quarter() : int
Return values
int —Quarter of the year.
season()
Returns this Jalali date's Iran/northern-hemisphere season.
public
final season() : Season
Tags
Return values
Season —Season enum value.
setTestToday()
Sets the date returned by today().
public
final static setTestToday(self|null $testToday) : void
Parameters
- $testToday : self|null
-
Date to return, or null to restore real time.
Tags
startOfMonth()
Returns the first day of this date's month.
public
final startOfMonth() : static
Return values
static —First day of month.
startOfQuarter()
Returns the first day of this date's quarter.
public
final startOfQuarter() : static
Return values
static —First day of quarter.
startOfWeek()
Returns the first day of this date's week.
public
final startOfWeek(int|DayOfWeek $firstDayOfWeek) : static
Parameters
- $firstDayOfWeek : int|DayOfWeek
-
Day of week considered as the start of the week.
Tags
Return values
static —Date starting the week.
startOfYear()
Returns the first day of this date's year.
public
final startOfYear() : static
Return values
static —First day of year.
toArray()
Returns the calendar components of this date as an array in [year, month, day] order.
public
final toArray() : array{0: int, 1: int, 2: int}
Return values
array{0: int, 1: int, 2: int} —Array of [year, month, day].
toCalendar()
Returns this civil day represented in the requested calendar system.
public
final toCalendar(Calendar $calendar) : self
Parameters
- $calendar : Calendar
-
Target calendar system.
Tags
Return values
self —Equivalent calendar date in the requested calendar system.
today()
Returns today's date in this calendar.
public
final static today() : static
Tags
Return values
static —Current date, or the deterministic test date when set.
toIso8601DateString()
Returns this date as a Gregorian ISO 8601 date string.
public
final toIso8601DateString() : string
Tags
Return values
string —Gregorian date in ISO 8601 YYYY-MM-DD form.
tomorrow()
Returns tomorrow's date in this calendar.
public
final static tomorrow() : static
Return values
static —Date one day after today.
weeksInMonth()
Returns the number of weeks spanned by this date's month.
public
final weeksInMonth(int|DayOfWeek $firstDayOfWeek) : int
Parameters
- $firstDayOfWeek : int|DayOfWeek
-
Day of week considered as the start of the week.
Tags
Return values
int —Number of weeks in the month.
weeksInYear()
Returns the number of weeks spanned by this date's year.
public
final weeksInYear(int|DayOfWeek $firstDayOfWeek) : int
Parameters
- $firstDayOfWeek : int|DayOfWeek
-
Day of week considered as the start of the week.
Tags
Return values
int —Number of weeks in the year.
withDay()
Returns a new date with a different day of month.
public
final withDay(int $day) : static
Parameters
- $day : int
-
New day of month.
Return values
static —Date with changed day.
withMonth()
Returns a new date with a different month.
public
final withMonth(int $month) : static
Parameters
- $month : int
-
New calendar month.
Return values
static —Date with changed month, with day clamped if needed.
withYear()
Returns a new date with a different year.
public
final withYear(int $year) : static
Parameters
- $year : int
-
New calendar year.
Tags
Return values
static —Date with changed year, with month or day clamped if needed.
year()
Returns the calendar year component.
public
final year() : int
Return values
int —Calendar year.
yesterday()
Returns yesterday's date in this calendar.
public
final static yesterday() : static
Return values
static —Date one day before today.
dateFromParsedFields()
Creates a date from parsed field values for the called calendar.
protected
static dateFromParsedFields(array<string, int|null> $fields) : static|null
Parameters
- $fields : array<string, int|null>
-
Parsed field values.
Tags
Return values
static|null —Date from the parsed fields, or null if the fields are insufficient to determine a date.
normalizeParseText()
Normalizes parse input and pattern text.
protected
static normalizeParseText(string $text, bool $stripBidiControls, bool $normalizeWhitespace) : string
Parameters
- $text : string
-
Text to normalize.
- $stripBidiControls : bool
-
Whether to strip Unicode bidi controls.
- $normalizeWhitespace : bool
-
Whether to trim and collapse whitespace.
Return values
string —Normalized text.
startOfMonthJDN()
Returns the Julian Day Number of the first day of this date's month.
protected
final startOfMonthJDN() : int
Return values
int —JDN of the first day of the month.
startOfYearJDN()
Returns the Julian Day Number of the first day of this date's year.
protected
final startOfYearJDN() : int
Return values
int —JDN of the first day of the year.
toDayOfWeek()
Validates a day of week value and returns a DayOfWeek instance.
protected
final static toDayOfWeek(int|DayOfWeek $dayOfWeek) : DayOfWeek
Parameters
- $dayOfWeek : int|DayOfWeek
-
Day of week value as an integer (0..6) or DayOfWeek instance.
Tags
Return values
DayOfWeek —Validated DayOfWeek instance.
toLocale()
Validates a locale value and returns a Locale instance.
protected
final static toLocale(Locale|string|null $locale) : Locale
Parameters
- $locale : Locale|string|null
-
Locale value as a language tag or Locale instance.
Tags
Return values
Locale —Validated Locale instance.
validateParsedFields()
Validates parsed property values against this date.
protected
validateParsedFields(array<string, int> $parsedProperties) : void
Parameters
- $parsedProperties : array<string, int>
-
Parsed property values to validate against this date.