diff options
author | Ruben Pollan | 2018-12-10 16:16:28 +0100 |
---|---|---|
committer | Ruben Pollan | 2018-12-10 16:16:28 +0100 |
commit | d0bb1ac385d1e81c07317f3148c4e2e6ddae3cfd (patch) | |
tree | b8aace05922c3d426b132fe477654cda89ff9c80 /src/date.rs | |
parent | 0afdb0b34eeefff033819f4f0930c960af8e17f8 (diff) |
Pretty print events
Diffstat (limited to 'src/date.rs')
-rw-r--r-- | src/date.rs | 18 |
1 files changed, 18 insertions, 0 deletions
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(), |