From d5d5fd92b7a7681c0188e1fb8abfef553a76b60c Mon Sep 17 00:00:00 2001 From: Toby Dimmick Date: Tue, 3 Apr 2018 13:42:03 +0100 Subject: [PATCH] impl Sub for for Date/Time types --- src/date.rs | 9 +++++++++ src/datetime.rs | 9 +++++++++ src/naive/date.rs | 9 +++++++++ src/naive/datetime.rs | 9 +++++++++ src/naive/time.rs | 9 +++++++++ 5 files changed, 45 insertions(+) diff --git a/src/date.rs b/src/date.rs index dba7dd0..f8b59ce 100644 --- a/src/date.rs +++ b/src/date.rs @@ -360,6 +360,15 @@ impl Sub for Date { } } +impl Sub> for Date { + type Output = OldDuration; + + #[inline] + fn sub(self, rhs: Date) -> OldDuration { + self.signed_duration_since(rhs) + } +} + impl fmt::Debug for Date { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{:?}{:?}", self.naive_local(), self.offset) diff --git a/src/datetime.rs b/src/datetime.rs index ec5e85a..2484807 100644 --- a/src/datetime.rs +++ b/src/datetime.rs @@ -485,6 +485,15 @@ impl Sub for DateTime { } } +impl Sub> for DateTime { + type Output = OldDuration; + + #[inline] + fn sub(self, rhs: DateTime) -> OldDuration { + self.signed_duration_since(rhs) + } +} + impl fmt::Debug for DateTime { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{:?}{:?}", self.naive_local(), self.offset) diff --git a/src/naive/date.rs b/src/naive/date.rs index df01e19..e5c363e 100644 --- a/src/naive/date.rs +++ b/src/naive/date.rs @@ -1378,6 +1378,15 @@ impl Sub for NaiveDate { } } +impl Sub for NaiveDate { + type Output = OldDuration; + + #[inline] + fn sub(self, rhs: NaiveDate) -> OldDuration { + self.signed_duration_since(rhs) + } +} + impl SubAssign for NaiveDate { #[inline] fn sub_assign(&mut self, rhs: OldDuration) { diff --git a/src/naive/datetime.rs b/src/naive/datetime.rs index b1212bf..b404cb9 100644 --- a/src/naive/datetime.rs +++ b/src/naive/datetime.rs @@ -1272,6 +1272,15 @@ impl Sub for NaiveDateTime { } } +impl Sub for NaiveDateTime { + type Output = OldDuration; + + #[inline] + fn sub(self, rhs: NaiveDateTime) -> OldDuration { + self.signed_duration_since(rhs) + } +} + impl SubAssign for NaiveDateTime { #[inline] fn sub_assign(&mut self, rhs: OldDuration) { diff --git a/src/naive/time.rs b/src/naive/time.rs index cbb6bf5..1c78165 100644 --- a/src/naive/time.rs +++ b/src/naive/time.rs @@ -1126,6 +1126,15 @@ impl Sub for NaiveTime { } } +impl Sub for NaiveTime { + type Output = OldDuration; + + #[inline] + fn sub(self, rhs: NaiveTime) -> OldDuration { + self.signed_duration_since(rhs) + } +} + impl SubAssign for NaiveTime { #[inline] fn sub_assign(&mut self, rhs: OldDuration) {