I've been going through the documentation for chrono
and chronoutil
for Rust but I think I am missing something when trying to add a month to a NaiveDate
.
I have a very simple Rust program:
use chrono::NaiveDate;
use chronoutil::relative_duration::RelativeDuration;
fn main() {
let start = NaiveDate::from_ymd(2020, 1, 31);
let one_month = RelativeDuration::months(1);
let end = start + one_month;
println!("{}", end.format("%Y-%m-%d").to_string());
}
But I am getting a mismatched types error on compile
let end = start + one_month;
^^^^^^^^^ expected struct `chrono::Duration`, found struct `RelativeDuration`
It doesn't seem very happy with me adding the RelativeDuration to the NaiveDate.
Including dependencies in Cargo.toml:
[dependencies]
chrono = "0.2.16"
chronoutil = "0.2.3"