Skip to main content

days_from_civil

Function days_from_civil 

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

Days since 1970-01-01 for a proleptic Gregorian date, exact for every i32 year.

NaiveDate only covers about ±262143 years, but the Gregorian calendar repeats every 400 years (146_097 days): chrono converts the year within its cycle and whole cycles are added back as days (an i128 so the i32 extremes can’t overflow). 1970-01-01 is num_days_from_ce 719_163; the result matches the proleptic Gregorian count the old hand-rolled code gave.