Skip to main content

Module date

Module date 

Expand description

Proleptic-Gregorian day counts for apps that label dates, on chrono.

Day 0 is 1970-01-01. Inputs often come straight from untrusted data (a message header, a file name, a spreadsheet cell), so nothing here panics or wraps: a date outside chrono’s range (about ±262,000 years) pins to the nearest end of it.

Functions§

civil_from_days
Inverse of days_from_civil: (year, month, day) for a count of days since 1970-01-01, with month in 1..=12 and day in 1..=31.
days_from_civil
Days since 1970-01-01 for a proleptic-Gregorian year/month/day (month 1..=12, day 1..=31). Day-of-month overflow rolls forward (Feb 30 is Mar 2 in a common year), which callers clamping with days_in_month never produce.
days_in_month
Number of days in month (1..=12) of year. A month outside 1..=12 reads as 30 rather than panicking.
weekday
Day of the week for a count of days since 1970-01-01, 0 = Sunday … 6 = Saturday — the index crate::format::weekday_abbrev takes.