From 9e69912aaddb7caa4efc578aae06d9015fddbfd9 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 26 Nov 2020 21:35:57 +0000 Subject: [PATCH] wip timestamp_abbreviate Signed-off-by: Ian Jackson --- wasm/wasm.rs | 5 +++++ zcoord/misc.rs | 4 +++- zcoord/zcoord.rs | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/wasm/wasm.rs b/wasm/wasm.rs index 5e7d6341..f7e03a9a 100644 --- a/wasm/wasm.rs +++ b/wasm/wasm.rs @@ -89,6 +89,11 @@ impl ZCoordIterator { } } +#[wasm_bindgen] +pub fn timestring_abbreviate(base: &str, now: &str) -> JsString { + zcoord::misc::timestring_abbreviate(base,now).0.into() +} + #[wasm_bindgen] pub fn setup(s: &str) -> JsString { // returning String produces a wasm-opt error, as here diff --git a/zcoord/misc.rs b/zcoord/misc.rs index 43531cc9..24152935 100644 --- a/zcoord/misc.rs +++ b/zcoord/misc.rs @@ -8,7 +8,9 @@ use if_chain::if_chain; use arrayvec::ArrayVec; -pub fn timesting_abbreviate<'x>(base: &str, this: &'x str) -> (&'x str, bool) { +pub fn timestring_abbreviate<'x>(base: &str, this: &'x str) + -> (&'x str, bool) +{ fn split(s: &str) -> ArrayVec<[&str; 3]> { s.splitn(3, ' ').collect() } diff --git a/zcoord/zcoord.rs b/zcoord/zcoord.rs index bab9cfd0..5c156b79 100644 --- a/zcoord/zcoord.rs +++ b/zcoord/zcoord.rs @@ -79,7 +79,7 @@ use thiserror::Error; use serde_with::DeserializeFromStr; use serde_with::SerializeDisplay; -mod misc; +pub mod misc; //---------- core definitions ---------- -- 2.30.2