如何向 Chrono UTC 添加天数?

How do I add days to a Chrono UTC?

我正在尝试找到向 Chrono 添加天数的首选方法 UTC。我想将 137 天添加到当前时间:

let dt = UTC::now();

只需使用Duration and appropriate operator:

use chrono::{Duration, Utc};

fn main() {
    let dt = Utc::now() + Duration::days(137);

    println!("today date + 137 days {}", dt);
}

Test on playground.

我只是想改进@Stargateur 的回答。不需要使用 time crate,因为 chrono crate 中有 Duration 结构:

extern crate chrono;

use chrono::{Duration, Utc};

fn main() {
    let dt = Utc::now() + Duration::days(137);

    println!("{}", dt);
}

Another test on playground