From d0bb1ac385d1e81c07317f3148c4e2e6ddae3cfd Mon Sep 17 00:00:00 2001 From: Ruben Pollan Date: Mon, 10 Dec 2018 16:16:28 +0100 Subject: Pretty print events --- src/date.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/date.rs') diff --git a/src/date.rs b/src/date.rs index 45a0c28..a4559e7 100644 --- a/src/date.rs +++ b/src/date.rs @@ -61,6 +61,24 @@ impl Date { Ok(date) } + pub fn format(&self, fmt: &str) -> String { + match *self { + Date::Time(t) => t.format(fmt).to_string(), + Date::AllDay(d) => d.format(fmt).to_string(), + } + } + + pub fn same_day(&self, other: &Date) -> bool { + self.day() == other.day() && self.month() == other.month() && self.year() == self.year() + } + + pub fn day(&self) -> u32 { + match *self { + Date::Time(t) => t.day(), + Date::AllDay(d) => d.day(), + } + } + pub fn month(&self) -> u32 { match *self { Date::Time(t) => t.month(), -- cgit v1.2.3