impl sub/add for fast datetime
@@ -2,8 +2,9 @@ use rbs::Value;
use serde::de::Error;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::fmt::{Display, Formatter};
-use std::ops::{Deref, DerefMut};
+use std::ops::{Add, Deref, DerefMut, Sub};
use std::str::FromStr;
+use std::time::Duration;
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
pub struct FastDateTime(pub fastdate::DateTime);
@@ -118,6 +119,31 @@ impl FastDateTime {
}
}
+impl Sub for FastDateTime {
+ type Output = Duration;
+
+ fn sub(self, rhs: Self) -> Self::Output {
+ self.0 - rhs.0
+ }
+}
+
+impl Add<Duration> for FastDateTime {
+ type Output = FastDateTime;
+
+ fn add(self, rhs: Duration) -> Self::Output {
+ FastDateTime(self.0.add(rhs))
+ }
+}
+
+impl Sub<Duration> for FastDateTime {
+ type Output = FastDateTime;
+
+ fn sub(self, rhs: Duration) -> Self::Output {
+ FastDateTime(self.0.sub(rhs))
+ }
+}
+
+
impl FromStr for FastDateTime {
type Err = crate::error::Error;
