Impl Display for DiaryId

This commit is contained in:
Matthias Beyer 2016-06-08 19:35:30 +02:00
parent de9d933a6b
commit b68bd7ef8e

View file

@ -1,4 +1,5 @@
use std::convert::Into;
use std::fmt::{Display, Formatter, Error as FmtError};
use chrono::naive::datetime::NaiveDateTime;
use chrono::naive::time::NaiveTime;
@ -133,6 +134,15 @@ impl Into<String> for DiaryId {
}
impl Display for DiaryId {
fn fmt(&self, fmt: &mut Formatter) -> Result<(), FmtError> {
write!(fmt, "{}/{:0>4}/{:0>2}/{:0>2}/{:0>2}:{:0>2}",
self.name, self.year, self.month, self.day, self.hour, self.minute)
}
}
impl Into<NaiveDateTime> for DiaryId {
fn into(self) -> NaiveDateTime {