time::macros

Macro date

Source
date!() { /* proc-macro */ }
Available on crate feature macros only.
Expand description

Construct a Date with a statically known value.

The resulting expression can be used in const or static declarations.

Three formats are supported: year-week-weekday, year-ordinal, and year-month-day.

assert_eq!(
    date!(2020 - W 01 - 3),
    Date::from_iso_week_date(2020, 1, Wednesday)?
);
assert_eq!(date!(2020-001), Date::from_ordinal_date(2020, 1)?);
assert_eq!(
    date!(2020-01-01),
    Date::from_calendar_date(2020, Month::January, 1)?
);