Function date

const fn date(year: i16, month: i8, day: i8) -> Date

Creates a new Date value in a const context.

This is a convenience free function for Date::constant. It is intended to provide a terse syntax for constructing Date values from parameters that are known to be valid.

Panics

This routine panics when Date::new would return an error. That is, when the given year-month-day does not correspond to a valid date. Namely, all of the following must be true:

Similarly, when used in a const context, invalid parameters will prevent your Rust program from compiling.

Example

use jiff::civil::date;

let d = date(2024, 2, 29);
assert_eq!(d.year(), 2024);
assert_eq!(d.month(), 2);
assert_eq!(d.day(), 29);