Add DiaryId::now(name) to create DiaryId at current time

This commit is contained in:
Matthias Beyer 2016-06-08 13:57:35 +02:00
parent 857daa1c99
commit de9d933a6b

View file

@ -92,6 +92,17 @@ impl DiaryId {
self
}
pub fn now(name: String) -> DiaryId {
use chrono::offset::local::Local;
let now = Local::now();
let now_date = now.date().naive_local();
let now_time = now.time();
let dt = NaiveDateTime::new(now_date, now_time);
DiaryId::new(name, dt.year(), dt.month(), dt.day(), dt.hour(), dt.minute())
}
}
impl Default for DiaryId {