Skip to content

std:datetime/Date

Canonical occurrence: protos/lib/datetime/Date.protos · Protos revision: e99b712ecf658a527b1fe82c8beba2c1286d8dc9.

Civil dates in the proleptic Gregorian calendar with astronomical year numbering: year 0 and negative years exist, the Gregorian leap-year rule extends backward without a Julian cutover, and the supported years are -9999 through 9999 inclusive. A date is a frozen ordinary object with Integer year, month, and day slots; it carries no time, offset, zone, or clock state.

Every date’s immediate delegation parent is this module, the canonical date factory and prototype. recognizes accepts exactly the dates of this family: objects whose immediate parent is this module and whose local slots are exactly the date state and behavior slots with a valid state. Matching slots under another parent are not a date.

Dates answer semantic equality through ==: two dates are equal when both are dates and their year, month, and day are equal. hash is coherent with that equality, so independently constructed equal dates work as the same Map key. === remains ordinary object identity. compare is the natural chronological order and answers 0 exactly for equal dates.

This page lists the complete mechanically observable top-level slot inventory required by D067. Authored documentation, when present, is canonical D062 prose; mechanical presence alone does not create a stability or compatibility promise.

Answers a fresh frozen date for year, month (1 through 12), and day (1 through the number of days of that month in that year). Every argument must be an Integer and year must lie in -9999 through 9999. An invalid or out-of-range field signals an Error; no field is clamped, wrapped, or normalized.

Answers -1, 0, or 1 as date left is chronologically before, equal to, or after date right, ordering by year, then month, then day. The result is 0 exactly when left == right. Arguments must be dates recognized by this module; otherwise an Error is signalled.

Answers true exactly when value is a date of this family: its immediate delegation parent is this module, its local slots are exactly year, month, day, equals, ==, and hash, and its fields form a valid date. Answers false for any other value.

Exact module source · Standard-library API · Standard library overview