Add support for Instant for wasm32.

This commit is contained in:
Stephen Chung
2020-06-17 16:50:57 +08:00
parent ae6d5e13a9
commit 2a73841549
5 changed files with 12 additions and 7 deletions

View File

@@ -1,5 +1,4 @@
#![cfg(not(target_arch = "wasm32"))]
#![cfg(not(feature = "no_std"))]
use super::logic::{eq, gt, gte, lt, lte, ne};
use super::math_basic::MAX_INT;
@@ -9,13 +8,15 @@ use crate::parser::INT;
use crate::result::EvalAltResult;
use crate::token::Position;
#[cfg(not(feature = "no_std"))]
#[cfg(not(target_arch = "wasm32"))]
use crate::stdlib::time::Instant;
#[cfg(target_arch = "wasm32")]
use instant::Instant;
#[cfg(not(feature = "no_float"))]
use crate::parser::FLOAT;
#[cfg(not(feature = "no_std"))]
def_package!(crate:BasicTimePackage:"Basic timing utilities.", lib, {
// Register date/time functions
lib.set_fn_0("timestamp", || Ok(Instant::now()));