Skip to content

DateOrder

How an all-numeric date reads: month first or day first.

'3/4/2026' is March 4th to an American and April 3rd to most of the rest of the world. Nothing in the text itself can settle it — so the reader asks you, with a DateOrder parameter. Only ambiguous shapes use it: ISO 8601 and bare '20260304' read the same everywhere, and a value whose first part has four digits is year-first no matter what you pass.

Members

Member Meaning
MonthFirst The US reading: '3/4/2026' is March 4th. This is the default.
DayFirst The European reading: '3/4/2026' is April 3rd.

Where it is used

Every method on CkDate that reads a date — ToCarbon, ToCarbonDay and their OrNull siblings, the writers, the validators and the calendar arithmetic — and the date readers on CkDictionary take an order parameter. The default is MonthFirst (CkSettings::DefaultDateOrder): declare the order once per data source, and an impossible date under it — '13/5/2026' read month first — is rejected, never quietly re-read the other way.

Quick look

use SafeCoder\CommonKit\CkDate;
use SafeCoder\CommonKit\Enums\DateOrder;

CkDate::ToCarbonDay('3/4/2026');      // -> CkDay 2026-03-04T00:00:00Z  (month first is the default)

CkDate::ToCarbonDay(
    input: '3/4/2026',
    order: DateOrder::DayFirst
);                                    // -> CkDay 2026-04-03T00:00:00Z

CkDate::ToCarbonDay('13/5/2026');     // -> Carbon 0001-01-01T00:00:00Z  (no month 13: rejected, not re-read)