Skip to main content

days_from_civil

Function days_from_civil 

Source
pub fn days_from_civil(y: i64, m: u8, d: u8) -> i64
Expand description

Days since the proleptic-Gregorian era for a calendar date (Howard Hinnant’s days_from_civil), valid for the full i64 year range.

The March-based year shift and mp = (m + 9) % 12 counting are what make the algorithm branch-free over the whole range; the OUTPUT’s zero is merely a consequence of the era/doe arithmetic and lands on 0000-03-01 (days_from_civil(0, 3, 1) == 0).

That zero is NOT the tick axis’s zero. Every family must share ONE origin, and the origin is fixed by the stored representation: an xsd:dateTime’s tick is read straight from its persisted Decimal seconds, which are XSD timeOnTimeline — zero at 0001-01-01. Calendar families are derived, so they must shift; see [AXIS_ORIGIN_DAYS] and tick_from_date.