如何用惯用方式获取现在和下一个午夜之间的持续时间?
我有一个这样的函数:
extern crate chrono;
use chrono::prelude::*;
use time;
fn duration_until_next_midnight() -> time::Duration {
let now = Local::now(); // Fri Dec 08 2017 23:00:00 GMT-0300 (-03)
// ... how to continue??
}
应该创建一个1小时的Duration
,因为下一个午夜是2017年12月9日周六00:00:00 GMT-0300 (-03)
let tomorrow_midnight = now + Duration::days(1);
就足够了。它将给出明天的日期,时间为00:00:00。 - azzamsa