From: Ian Jackson Date: Thu, 26 Nov 2020 21:35:57 +0000 (+0000) Subject: wip timestamp_abbreviate X-Git-Tag: otter-0.2.0~348 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=9e69912aaddb7caa4efc578aae06d9015fddbfd9;p=otter.git wip timestamp_abbreviate Signed-off-by: Ian Jackson --- 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 ----------