Function chronoutil::delta::with_year

source ·
pub fn with_year<D: Datelike>(date: D, year: i32) -> D
Expand description

Shift the date to have the given year.

Ambiguous month-ends are shifted backwards as necessary. For example:

let start = NaiveDate::from_ymd_opt(2020, 2, 29).unwrap();
assert_eq!(with_year(start, 2021), NaiveDate::from_ymd_opt(2021, 2, 28).unwrap());