impl Sub<T> for <T> for Date/Time types

This commit is contained in:
Toby Dimmick 2018-04-03 13:42:03 +01:00
parent 5aabc29a1f
commit d5d5fd92b7
5 changed files with 45 additions and 0 deletions

View File

@ -360,6 +360,15 @@ impl<Tz: TimeZone> Sub<OldDuration> for Date<Tz> {
}
}
impl<Tz: TimeZone> Sub<Date<Tz>> for Date<Tz> {
type Output = OldDuration;
#[inline]
fn sub(self, rhs: Date<Tz>) -> OldDuration {
self.signed_duration_since(rhs)
}
}
impl<Tz: TimeZone> fmt::Debug for Date<Tz> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}{:?}", self.naive_local(), self.offset)

View File

@ -485,6 +485,15 @@ impl<Tz: TimeZone> Sub<OldDuration> for DateTime<Tz> {
}
}
impl<Tz: TimeZone> Sub<DateTime<Tz>> for DateTime<Tz> {
type Output = OldDuration;
#[inline]
fn sub(self, rhs: DateTime<Tz>) -> OldDuration {
self.signed_duration_since(rhs)
}
}
impl<Tz: TimeZone> fmt::Debug for DateTime<Tz> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}{:?}", self.naive_local(), self.offset)

View File

@ -1378,6 +1378,15 @@ impl Sub<OldDuration> for NaiveDate {
}
}
impl Sub<NaiveDate> for NaiveDate {
type Output = OldDuration;
#[inline]
fn sub(self, rhs: NaiveDate) -> OldDuration {
self.signed_duration_since(rhs)
}
}
impl SubAssign<OldDuration> for NaiveDate {
#[inline]
fn sub_assign(&mut self, rhs: OldDuration) {

View File

@ -1272,6 +1272,15 @@ impl Sub<OldDuration> for NaiveDateTime {
}
}
impl Sub<NaiveDateTime> for NaiveDateTime {
type Output = OldDuration;
#[inline]
fn sub(self, rhs: NaiveDateTime) -> OldDuration {
self.signed_duration_since(rhs)
}
}
impl SubAssign<OldDuration> for NaiveDateTime {
#[inline]
fn sub_assign(&mut self, rhs: OldDuration) {

View File

@ -1126,6 +1126,15 @@ impl Sub<OldDuration> for NaiveTime {
}
}
impl Sub<NaiveTime> for NaiveTime {
type Output = OldDuration;
#[inline]
fn sub(self, rhs: NaiveTime) -> OldDuration {
self.signed_duration_since(rhs)
}
}
impl SubAssign<OldDuration> for NaiveTime {
#[inline]
fn sub_assign(&mut self, rhs: OldDuration) {