diff options
Diffstat (limited to 'src/date.rs')
-rw-r--r-- | src/date.rs | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/date.rs b/src/date.rs index 49b8b05..ab9d66c 100644 --- a/src/date.rs +++ b/src/date.rs @@ -27,43 +27,37 @@ impl Deref for Date { fn deref(&self) -> &NaiveDateTime { &self.0 } - } impl DerefMut for Date { - fn deref_mut(&mut self) -> &mut NaiveDateTime { &mut self.0 } - } impl From<NaiveDateTime> for Date { - fn from(ndt: NaiveDateTime) -> Date { Date(ndt) } - } /// The date-time parsing template used to parse the date time data exported by taskwarrior. -pub static TASKWARRIOR_DATETIME_TEMPLATE : &'static str = "%Y%m%dT%H%M%SZ"; +pub static TASKWARRIOR_DATETIME_TEMPLATE: &'static str = "%Y%m%dT%H%M%SZ"; impl Serialize for Date { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where S: Serializer + where + S: Serializer, { let formatted = self.0.format(TASKWARRIOR_DATETIME_TEMPLATE); serializer.serialize_str(&format!("{}", formatted)) } - } impl<'de> Deserialize<'de> for Date { - fn deserialize<D>(deserializer: D) -> Result<Date, D::Error> - where D: Deserializer<'de> + where + D: Deserializer<'de>, { struct DateVisitor; @@ -71,11 +65,16 @@ impl<'de> Deserialize<'de> for Date { type Value = Date; fn expecting(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - write!(fmt, "a string which matches {}", TASKWARRIOR_DATETIME_TEMPLATE) + write!( + fmt, + "a string which matches {}", + TASKWARRIOR_DATETIME_TEMPLATE + ) } fn visit_str<E>(self, value: &str) -> Result<Date, E> - where E: SerdeError + where + E: SerdeError, { NaiveDateTime::parse_from_str(value, TASKWARRIOR_DATETIME_TEMPLATE) .map(|d| Date(d)) @@ -85,5 +84,4 @@ impl<'de> Deserialize<'de> for Date { deserializer.deserialize_str(DateVisitor) } - } |