You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can use Reflect to call it directly. Here's a wrapper I made to do this.
use js_sys::{Date,Reflect};use wasm_bindgen::JsValue;pubfnto_local_time_string(date:&Date,locale:&str,options:&JsValue) -> Result<String,JsValue>{let method = Reflect::get(&date.into(),&JsValue::from("toLocaleTimeString"))?;let result = js_sys::Function::from(method).call2(&date.clone().into(),&JsValue::from(locale),
options,)?;// Convert the result to a string and return
result
.as_string().ok_or_else(|| JsValue::from("Failed to convert to string"))}
The text was updated successfully, but these errors were encountered:
According to the MDN docs, toLocalTimeString takes an options parameter but it's missing from js-sys
js-sys::Date.to_locale_time_string
Workaround
You can use Reflect to call it directly. Here's a wrapper I made to do this.
The text was updated successfully, but these errors were encountered: