Fix no_float bug in time.

This commit is contained in:
Stephen Chung
2020-10-09 13:47:35 +08:00
parent b23966e16b
commit 95c4ac4180
2 changed files with 31 additions and 25 deletions

View File

@@ -34,10 +34,10 @@ mod time_functions {
pub fn elapsed(timestamp: &mut Instant) -> Result<Dynamic, Box<EvalAltResult>> {
#[cfg(not(feature = "no_float"))]
{
if *timestamp <= Instant::now() {
Ok((timestamp.elapsed().as_secs_f64() as FLOAT).into())
} else {
if *timestamp > Instant::now() {
Err(make_arithmetic_err("Time-stamp is later than now"))
} else {
Ok((timestamp.elapsed().as_secs_f64() as FLOAT).into())
}
}
@@ -50,7 +50,7 @@ mod time_functions {
"Integer overflow for timestamp.elapsed: {}",
seconds
)))
} else if *timestamp <= Instant::now() {
} else if *timestamp > Instant::now() {
Err(make_arithmetic_err("Time-stamp is later than now"))
} else {
Ok((seconds as INT).into())