Skip to content

Commit

Permalink
Reverting to previous good commit
Browse files Browse the repository at this point in the history
  • Loading branch information
daidoji committed Jan 3, 2024
1 parent 90a7e71 commit 43e1988
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion wasm/demo/node/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Dater } from "cesride-wasm";

function main() {
const date = new Dater("2020-08-22T17:50:09.988921+00:00", undefined, undefined, undefined, undefined, undefined);
const date = Dater.new_with_dts("2020-08-22T17:50:09.988921+00:00");
console.log("<p>Date:</p>");
console.log("dts: " + date.dts + "<br/>");
console.log("dtsb: " + date.dtsb + "<br/>");
Expand Down
4 changes: 2 additions & 2 deletions wasm/demo/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
await init();

let dts = "2020-08-22T17:50:09.988921+00:00";
let dater = new Dater(dts, undefined, undefined, undefined, undefined, undefined);
let dater = Dater.new_with_dts(dts);
document.write("<p>Date:</p>");
document.write("<code>")
document.write("dts: " + dater.dts + "<br/>");
Expand All @@ -57,7 +57,7 @@
document.write("qb64b: " + dater.qb64b + "<br/>");
document.write("qb2: " + dater.qb2 + "<br/>");
try {
dater = new Dater("asdf", undefined, undefined, undefined, undefined, undefined);
dater = Dater.new_with_dts(dts = "asdf");
document.write("Wrong dater: " + dater.dts + "<br/>");
} catch (error) {
document.write("Error: " + error + "<br/>");
Expand Down
2 changes: 1 addition & 1 deletion wasm/demo/webpack/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ document.write(`
`)

let dts = "2020-08-22T17:50:09.988921+00:00";
let dater = new cesride.Dater(dts, undefined, undefined, undefined, undefined, undefined);
let dater = cesride.Dater.new_with_dts(dts);

const icp = {
"v": "KERI10JSON00015a_",
Expand Down
25 changes: 25 additions & 0 deletions wasm/src/primitives/dater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,31 @@ impl DaterWrapper {
Ok(DaterWrapper(dater))
}

pub fn new_with_dts(dts: &str, code: Option<String>) -> Result<DaterWrapper> {
let dater = Dater::new_with_dts(dts, code.as_deref()).as_js()?;
Ok(DaterWrapper(dater))
}

pub fn new_with_raw(raw: &[u8], code: Option<String>) -> Result<DaterWrapper> {
let dater = Dater::new_with_raw(raw, code.as_deref()).as_js()?;
Ok(DaterWrapper(dater))
}

pub fn new_with_qb64b(qb64b: &[u8]) -> Result<DaterWrapper> {
let dater = Dater::new_with_qb64b(qb64b).as_js()?;
Ok(DaterWrapper(dater))
}

pub fn new_with_qb64(qb64: &str) -> Result<DaterWrapper> {
let dater = Dater::new_with_qb64(qb64).as_js()?;
Ok(DaterWrapper(dater))
}

pub fn new_with_qb2(qb2: &[u8]) -> Result<DaterWrapper> {
let dater = Dater::new_with_qb2(qb2).as_js()?;
Ok(DaterWrapper(dater))
}

#[wasm_bindgen(getter)]
pub fn dts(&self) -> Result<String> {
self.0.dts().as_js().map_err(JsValue::from)
Expand Down

0 comments on commit 43e1988

Please sign in to comment.