feat: patch chrono

This commit is contained in:
2023-01-20 23:25:18 +08:00
parent cf8e579f27
commit c997aab841
71 changed files with 27208 additions and 178 deletions

View File

@@ -29,11 +29,11 @@ core-foundation-sys = "0.8.3"
windows-sys = { version = "0.42.0", features = ["Win32_Globalization", "Win32_System_Com", "Win32_System_WinRT"] }
[target.'cfg(target_arch = "wasm32")'.dependencies]
js-sys = "0.3.50"
wasm-bindgen = "0.2.70"
#js-sys = "0.3.50"
#wasm-bindgen = "0.2.70"
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test = "0.3"
#wasm-bindgen-test = "0.3"
[target.'cfg(target_os = "haiku")'.dependencies]
iana-time-zone-haiku = { version = "0.1.1", path = "haiku" }

View File

@@ -1,21 +1,22 @@
use js_sys::{Array, Intl, Object, Reflect};
use wasm_bindgen::JsValue;
// use js_sys::{Array, Intl, Object, Reflect};
// use wasm_bindgen::JsValue;
pub(crate) fn get_timezone_inner() -> Result<String, crate::GetTimezoneError> {
let intl = Intl::DateTimeFormat::new(&Array::new(), &Object::new()).resolved_options();
Reflect::get(&intl, &JsValue::from_str("timeZone"))
.ok()
.and_then(|tz| tz.as_string())
.ok_or(crate::GetTimezoneError::OsError)
// let intl = Intl::DateTimeFormat::new(&Array::new(), &Object::new()).resolved_options();
// Reflect::get(&intl, &JsValue::from_str("timeZone"))
// .ok()
// .and_then(|tz| tz.as_string())
// .ok_or(crate::GetTimezoneError::OsError)
Ok("Europe/London".into())
}
#[cfg(test)]
mod tests {
use wasm_bindgen_test::*;
#[wasm_bindgen_test]
fn pass() {
let tz = super::get_timezone_inner().unwrap();
console_log!("tz={:?}", tz);
}
}
// #[cfg(test)]
// mod tests {
// use wasm_bindgen_test::*;
//
// #[wasm_bindgen_test]
// fn pass() {
// let tz = super::get_timezone_inner().unwrap();
// console_log!("tz={:?}", tz);
// }
// }