Skip to main content

Module date

Module date 

Source
Expand description

Date and time conversion helpers.

Mirrors the logic in Go date.go, converting between Excel serial numbers and chrono naive date/time types while accounting for the 1900/1904 date system and the Excel 1900 leap-year bug.

Structs§

Date
Convenience helper for date/time conversions used elsewhere in the crate.

Constants§

EXCEL_BUGGY_PERIOD_START
Start of the period affected by the Excel 1900 leap-year bug (1900-03-01).
EXCEL_EPOCH_1900
Forward-conversion epoch for the 1900 date system (1899-12-31).
EXCEL_EPOCH_1904
Excel epoch for the 1904 date system (1904-01-01).
EXCEL_MIN_TIME_1900
Earliest representable date in the 1900 date system.
EXCEL_REVERSE_EPOCH_1900
Reverse-conversion epoch for the 1900 date system (1899-12-30).

Functions§

date_to_excel_serial
Convert a NaiveDate to an Excel serial number.
datetime_to_excel_serial
Convert a NaiveDateTime to an Excel serial number.
excel_serial_to_datetime
Convert an Excel serial number to a NaiveDateTime.
format_year
Convert a 2-digit year into a 4-digit year using Excel’s 30/1900 rule.
get_days_in_month
Return the number of days in the given month.
is_leap_year
Determine whether a year is a leap year.
time_to_excel_serial
Convert a NaiveTime to the fractional part of an Excel day.
validate_date
Validate whether the given year, month and day form a legal date.