【发布时间】:2020-07-17 08:04:14
【问题描述】:
我正在使用 chrono 板条箱并希望计算两个 DateTimes 之间的 Duration。
use chrono::Utc;
use chrono::offset::TimeZone;
let start_of_period = Utc.ymd(2020, 1, 1).and_hms(0, 0, 0);
let end_of_period = Utc.ymd(2021, 1, 1).and_hms(0, 0, 0);
// What should I enter here?
//
// The goal is to find a duration so that
// start_of_period + duration == end_of_period
// I expect duration to be of type std::time
let duration = ...
let nb_of_days = duration.num_days();
【问题讨论】:
标签: rust rust-chrono