DXNDate
in package
implements
DXNValueInterface
DXN `date` (`~D[YYYY-MM-DD]`) -- a bare calendar date, ISO 8601.
Table of Contents
Interfaces
- DXNValueInterface
- Implemented by every `DXN*` wrapper class -- the PHP analog of the `dxnType` string tag used for kind dispatch in the JS port, and of `Dextrin.Value`'s closed type union in the Elixir original. Native PHP values (`null`, `bool`, `int`, `float`, `string`, and `array` for `map`/`array`) never implement this; {@see Equality::kindOf()} handles those directly.
Constants
- DXN_TYPE : mixed = 'date'
Properties
Methods
- __construct() : mixed
- compareTo() : int
- A total order against any other DXN value, not just another instance of this class -- backs {@see DXNSortedSet}. Cross-kind ordering is implementation-defined per DXN.md; within a kind, uses the kind's own natural order where one exists, or a deterministic structural fallback where it doesn't.
- dxnType() : string
- The DXN type name this value represents, e.g. "symbol", "uuid".
- equals() : bool
- Structural equality, recursing into nested DXN values as needed.
- fromDateTimeImmutable() : self
- Reads the UTC Y/M/D of `$date`, discarding time-of-day and any non-UTC offset.
- toDateTimeImmutable() : DateTimeImmutable
- A `DateTimeImmutable` at UTC midnight -- a documented, one-way -safe convention for a bare-date type PHP has no exact native equivalent for (`DateTimeImmutable` always carries a time and a zone; midnight UTC is the least-surprising synthetic choice).
- daysInMonth() : int
- Hand-rolled rather than `checkdate()`, which only supports years 1..32767 -- DXN's own date range isn't bounded that way, and `checkdate`'s year clamping would silently misjudge leap years outside that range.
- isLeapYear() : bool
Constants
DXN_TYPE
private
mixed
DXN_TYPE
= 'date'
Properties
$day read-only
public
int
$day
$month read-only
public
int
$month
$year read-only
public
int
$year
Methods
__construct()
public
__construct(int $year, int $month, int $day) : mixed
Parameters
- $year : int
- $month : int
- $day : int
compareTo()
A total order against any other DXN value, not just another instance of this class -- backs {@see DXNSortedSet}. Cross-kind ordering is implementation-defined per DXN.md; within a kind, uses the kind's own natural order where one exists, or a deterministic structural fallback where it doesn't.
public
compareTo(mixed $other) : int
Parameters
- $other : mixed
Return values
intdxnType()
The DXN type name this value represents, e.g. "symbol", "uuid".
public
dxnType() : string
Return values
stringequals()
Structural equality, recursing into nested DXN values as needed.
public
equals(mixed $other) : bool
Parameters
- $other : mixed
Return values
boolfromDateTimeImmutable()
Reads the UTC Y/M/D of `$date`, discarding time-of-day and any non-UTC offset.
public
static fromDateTimeImmutable(DateTimeImmutable $date) : self
Parameters
- $date : DateTimeImmutable
Return values
selftoDateTimeImmutable()
A `DateTimeImmutable` at UTC midnight -- a documented, one-way -safe convention for a bare-date type PHP has no exact native equivalent for (`DateTimeImmutable` always carries a time and a zone; midnight UTC is the least-surprising synthetic choice).
public
toDateTimeImmutable() : DateTimeImmutable
Return values
DateTimeImmutabledaysInMonth()
Hand-rolled rather than `checkdate()`, which only supports years 1..32767 -- DXN's own date range isn't bounded that way, and `checkdate`'s year clamping would silently misjudge leap years outside that range.
private
static daysInMonth(int $year, int $month) : int
Parameters
- $year : int
- $month : int
Return values
intisLeapYear()
private
static isLeapYear(int $year) : bool
Parameters
- $year : int