Remove <datetime> / <duration> functionality in favour of time::floor function
Closes #1213
This commit is contained in:
parent
d141605266
commit
25926cba83
2 changed files with 3 additions and 37 deletions
|
@ -3,7 +3,6 @@ use crate::sql::datetime::Datetime;
|
||||||
use crate::sql::error::IResult;
|
use crate::sql::error::IResult;
|
||||||
use crate::sql::serde::is_internal_serialization;
|
use crate::sql::serde::is_internal_serialization;
|
||||||
use crate::sql::value::Value;
|
use crate::sql::value::Value;
|
||||||
use chrono::DurationRound;
|
|
||||||
use nom::branch::alt;
|
use nom::branch::alt;
|
||||||
use nom::bytes::complete::tag;
|
use nom::bytes::complete::tag;
|
||||||
use nom::multi::many1;
|
use nom::multi::many1;
|
||||||
|
@ -204,19 +203,6 @@ impl ops::Sub<Datetime> for Duration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ops::Div<Datetime> for Duration {
|
|
||||||
type Output = Datetime;
|
|
||||||
fn div(self, other: Datetime) -> Datetime {
|
|
||||||
match chrono::Duration::from_std(self.0) {
|
|
||||||
Ok(d) => match other.duration_trunc(d) {
|
|
||||||
Ok(v) => Datetime::from(v),
|
|
||||||
Err(_) => Datetime::default(),
|
|
||||||
},
|
|
||||||
Err(_) => Datetime::default(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Sum<Self> for Duration {
|
impl Sum<Self> for Duration {
|
||||||
fn sum<I>(iter: I) -> Duration
|
fn sum<I>(iter: I) -> Duration
|
||||||
where
|
where
|
||||||
|
|
|
@ -1229,29 +1229,9 @@ impl ops::Mul for Value {
|
||||||
impl ops::Div for Value {
|
impl ops::Div for Value {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn div(self, other: Self) -> Self {
|
fn div(self, other: Self) -> Self {
|
||||||
match (self, other) {
|
match (self.as_number(), other.as_number()) {
|
||||||
(Value::Number(v), Value::Number(w)) => {
|
(_, w) if w == Number::Int(0) => Value::None,
|
||||||
if w == Number::Int(0) {
|
(v, w) => Value::Number(v / w),
|
||||||
Value::None
|
|
||||||
} else {
|
|
||||||
Value::Number(v / w)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
(Value::Datetime(v), Value::Duration(w)) => {
|
|
||||||
if w.is_zero() {
|
|
||||||
Value::None
|
|
||||||
} else {
|
|
||||||
Value::Datetime(w / v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
(v, w) => {
|
|
||||||
let w = w.as_number();
|
|
||||||
if w == Number::Int(0) {
|
|
||||||
Value::None
|
|
||||||
} else {
|
|
||||||
Value::from(v.as_number() / w)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue