From b68bd7ef8eb1b7a887db116fb91aa8e8c0a59bcf Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 8 Jun 2016 19:35:30 +0200 Subject: [PATCH] Impl Display for DiaryId --- libimagdiary/src/diaryid.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libimagdiary/src/diaryid.rs b/libimagdiary/src/diaryid.rs index fb9c0c34..5549ac17 100644 --- a/libimagdiary/src/diaryid.rs +++ b/libimagdiary/src/diaryid.rs @@ -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 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 for DiaryId { fn into(self) -> NaiveDateTime {