Split unit into duration and filesize (#3453)

This commit is contained in:
JT
2021-05-21 13:21:46 +12:00
committed by GitHub
parent 4fdbf30308
commit 28388b4e3a
6 changed files with 126 additions and 38 deletions

View File

@ -438,6 +438,15 @@ pub fn compute_values(
Err(_) => Err(("Date", "Duration overflow")),
}
}
Operator::Minus => {
match Primitive::into_chrono_duration(rhs.clone(), Span::unknown()) {
Ok(y) => match x.checked_sub_signed(y) {
Some(value) => Ok(value),
None => Err(("Date", "Duration and date addition overflow")),
},
Err(_) => Err(("Date", "Duration overflow")),
}
}
_ => Err((left.type_name(), right.type_name())),
}?;
Ok(UntaggedValue::Primitive(Primitive::Date(result)))