From a4fad50160123c225d6faa2ba376c0bfdc87fdea Mon Sep 17 00:00:00 2001 From: tottoto Date: Tue, 8 Aug 2023 05:32:11 +0900 Subject: [PATCH] Update to time 0.3 --- Cargo.lock | 171 ++----------------------------------- lib/emscripten/Cargo.toml | 2 +- lib/emscripten/src/time.rs | 27 +++--- lib/wasi-types/Cargo.toml | 2 +- lib/wasi-web/Cargo.lock | 171 +++++-------------------------------- 5 files changed, 50 insertions(+), 323 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 38284d75f5b..211b86c4a91 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -267,12 +267,6 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "base-x" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" - [[package]] name = "base64" version = "0.21.2" @@ -716,12 +710,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "const_fn" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbdcdcb6d86f71c5e97409ad45898af11cbc995b4ee8112d59095a28d376c935" - [[package]] name = "constant_time_eq" version = "0.3.0" @@ -1303,12 +1291,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "discard" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" - [[package]] name = "distance" version = "0.4.0" @@ -3559,15 +3541,6 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver 0.9.0", -] - [[package]] name = "rustc_version" version = "0.3.3" @@ -3822,22 +3795,13 @@ dependencies = [ "libc", ] -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser 0.7.0", -] - [[package]] name = "semver" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" dependencies = [ - "semver-parser 0.10.2", + "semver-parser", ] [[package]] @@ -3849,12 +3813,6 @@ dependencies = [ "serde", ] -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - [[package]] name = "semver-parser" version = "0.10.2" @@ -4014,21 +3972,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "sha1" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1da05c97445caa12d05e848c4a4fcbbea29e748ac28f7e80e9b010392063770" -dependencies = [ - "sha1_smol", -] - -[[package]] -name = "sha1_smol" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" - [[package]] name = "sha2" version = "0.10.7" @@ -4171,70 +4114,12 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" -[[package]] -name = "standback" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e113fb6f3de07a243d434a56ec6f186dfd51cb08448239fe7bcae73f87ff28ff" -dependencies = [ - "version_check", -] - [[package]] name = "static_assertions" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "stdweb" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5" -dependencies = [ - "discard", - "rustc_version 0.2.3", - "stdweb-derive", - "stdweb-internal-macros", - "stdweb-internal-runtime", - "wasm-bindgen", -] - -[[package]] -name = "stdweb-derive" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" -dependencies = [ - "proc-macro2", - "quote", - "serde", - "serde_derive", - "syn 1.0.109", -] - -[[package]] -name = "stdweb-internal-macros" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" -dependencies = [ - "base-x", - "proc-macro2", - "quote", - "serde", - "serde_derive", - "serde_json", - "sha1", - "syn 1.0.109", -] - -[[package]] -name = "stdweb-internal-runtime" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" - [[package]] name = "strsim" version = "0.10.0" @@ -4440,21 +4325,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "time" -version = "0.2.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4752a97f8eebd6854ff91f1c1824cd6160626ac4bd44287f7f4ea2035a02a242" -dependencies = [ - "const_fn", - "libc", - "standback", - "stdweb", - "time-macros 0.1.1", - "version_check", - "winapi", -] - [[package]] name = "time" version = "0.3.25" @@ -4465,7 +4335,7 @@ dependencies = [ "itoa", "serde", "time-core", - "time-macros 0.2.11", + "time-macros", ] [[package]] @@ -4474,16 +4344,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" -[[package]] -name = "time-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957e9c6e26f12cb6d0dd7fc776bb67a706312e7299aed74c8dd5b17ebb27e2f1" -dependencies = [ - "proc-macro-hack", - "time-macros-impl", -] - [[package]] name = "time-macros" version = "0.2.11" @@ -4493,19 +4353,6 @@ dependencies = [ "time-core", ] -[[package]] -name = "time-macros-impl" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd3c141a1b43194f3f56a1411225df8646c55781d5f26db825b3d98507eb482f" -dependencies = [ - "proc-macro-hack", - "proc-macro2", - "quote", - "standback", - "syn 1.0.109", -] - [[package]] name = "tinytemplate" version = "1.2.1" @@ -5433,7 +5280,7 @@ dependencies = [ "serde", "serde_json", "serde_path_to_error", - "time 0.3.25", + "time", "tracing", "url", "wasmer-deploy-schema", @@ -5720,7 +5567,7 @@ dependencies = [ "serde", "serde_json", "serde_yaml 0.8.26", - "time 0.3.25", + "time", "tokio", "toml 0.7.6", "tracing", @@ -5748,7 +5595,7 @@ dependencies = [ "serde_json", "serde_path_to_error", "serde_yaml 0.8.26", - "time 0.3.25", + "time", "url", "uuid", "wcgi-host", @@ -5787,7 +5634,7 @@ dependencies = [ "lazy_static", "libc", "log", - "time 0.2.27", + "time", "wasmer", "wasmer-types", ] @@ -5901,7 +5748,7 @@ dependencies = [ "tar", "tempfile", "thiserror", - "time 0.3.25", + "time", "tldextract", "tokio", "toml 0.5.11", @@ -5942,7 +5789,7 @@ dependencies = [ "tar", "tempfile", "thiserror", - "time 0.3.25", + "time", "tldextract", "tokio", "toml 0.5.11", @@ -6139,7 +5986,7 @@ dependencies = [ "num_enum", "pretty_assertions", "serde", - "time 0.2.27", + "time", "tracing", "wai-bindgen-gen-core", "wai-bindgen-gen-rust", diff --git a/lib/emscripten/Cargo.toml b/lib/emscripten/Cargo.toml index ffe497d3ae1..997eb36ca63 100644 --- a/lib/emscripten/Cargo.toml +++ b/lib/emscripten/Cargo.toml @@ -17,7 +17,7 @@ byteorder = "1.3" lazy_static = "1.4" libc = "^0.2" log = "0.4" -time = { version = "0.2", features = ["std"] } +time = { version = "0.3", features = ["std", "formatting"] } wasmer = { path = "../api", version = "=4.1.1", default-features = false } wasmer-types = { path = "../types", version = "=4.1.1" } diff --git a/lib/emscripten/src/time.rs b/lib/emscripten/src/time.rs index 3b6f7100bf2..d4c62c60f66 100644 --- a/lib/emscripten/src/time.rs +++ b/lib/emscripten/src/time.rs @@ -247,7 +247,7 @@ pub fn _localtime(mut ctx: FunctionEnvMut, time_p: u32) -> c_int { let timespec = unsafe { let time_p_addr = emscripten_memory_pointer!(memory.view(&ctx), time_p) as *mut i64; let seconds = *time_p_addr; - time::OffsetDateTime::from_unix_timestamp(seconds) + time::OffsetDateTime::from_unix_timestamp(seconds).unwrap() }; unsafe { @@ -285,7 +285,7 @@ pub fn _localtime_r(ctx: FunctionEnvMut, time_p: u32, result: u32) -> c_i let memory = ctx.data().memory(0); unsafe { let seconds = emscripten_memory_pointer!(memory.view(&ctx), time_p) as *const i32; - let timespec = time::OffsetDateTime::from_unix_timestamp_nanos(*seconds as _); + let timespec = time::OffsetDateTime::from_unix_timestamp_nanos(*seconds as _).unwrap(); // debug!( // ">>>>>>> time = {}, {}, {}, {}, {}, {}, {}, {}", @@ -419,18 +419,23 @@ pub fn _strftime( let tm = unsafe { &*tm }; - let rust_date = time::Date::try_from_ymd(tm.tm_year, tm.tm_mon as u8, tm.tm_mday as u8); - if rust_date.is_err() { + let Ok(rust_date) = time::Date::from_calendar_date( + tm.tm_year, + time::Month::try_from(tm.tm_mon as u8).unwrap(), + tm.tm_mday as u8, + ) else { return 0; - } - let rust_time = time::Time::try_from_hms(tm.tm_hour as u8, tm.tm_min as u8, tm.tm_sec as u8); - if rust_time.is_err() { + }; + let Ok(rust_time) = time::Time::from_hms(tm.tm_hour as u8, tm.tm_min as u8, tm.tm_sec as u8) else { return 0; - } - let rust_datetime = time::PrimitiveDateTime::new(rust_date.unwrap(), rust_time.unwrap()); - let rust_odt = rust_datetime.assume_offset(time::UtcOffset::seconds(tm.tm_gmtoff)); + }; + let rust_datetime = time::PrimitiveDateTime::new(rust_date, rust_time); + let rust_odt = + rust_datetime.assume_offset(time::UtcOffset::from_whole_seconds(tm.tm_gmtoff).unwrap()); - let result_str = rust_odt.format(format_string); + let result_str = rust_odt + .format(&time::format_description::parse(format_string).unwrap()) + .unwrap(); // pad for null? let bytes = result_str.chars().count(); diff --git a/lib/wasi-types/Cargo.toml b/lib/wasi-types/Cargo.toml index 1cdb6b67802..897c967288a 100644 --- a/lib/wasi-types/Cargo.toml +++ b/lib/wasi-types/Cargo.toml @@ -29,7 +29,7 @@ bitflags = "1.3.0" cfg-if = "1.0.0" anyhow = "1.0.66" byteorder = "1.3" -time = "0.2" +time = { version = "0.3", features = ["formatting"] } tracing = { version = "0.1.37" } [dev-dependencies.pretty_assertions] diff --git a/lib/wasi-web/Cargo.lock b/lib/wasi-web/Cargo.lock index 11674ad24ec..172705a0995 100644 --- a/lib/wasi-web/Cargo.lock +++ b/lib/wasi-web/Cargo.lock @@ -105,12 +105,6 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "base-x" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" - [[package]] name = "base64" version = "0.13.1" @@ -262,12 +256,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "const_fn" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbdcdcb6d86f71c5e97409ad45898af11cbc995b4ee8112d59095a28d376c935" - [[package]] name = "cooked-waker" version = "5.0.0" @@ -409,6 +397,12 @@ dependencies = [ "parking_lot_core 0.9.8", ] +[[package]] +name = "deranged" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7684a49fb1af197853ef7b2ee694bc1f5b4179556f1e5710e1760c5db6f5e929" + [[package]] name = "derivative" version = "2.2.0" @@ -470,12 +464,6 @@ dependencies = [ "crypto-common", ] -[[package]] -name = "discard" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" - [[package]] name = "dummy-waker" version = "1.1.0" @@ -776,7 +764,7 @@ checksum = "db04bc24a18b9ea980628ecf00e6c0264f3c1426dac36c00cb49b6fbad8b0743" dependencies = [ "atomic-polyfill", "hash32", - "rustc_version 0.4.0", + "rustc_version", "spin", "stable_deref_trait", ] @@ -1220,12 +1208,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "proc-macro-hack" -version = "0.5.20+deprecated" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" - [[package]] name = "proc-macro2" version = "1.0.66" @@ -1420,22 +1402,13 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver 0.9.0", -] - [[package]] name = "rustc_version" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.18", + "semver", ] [[package]] @@ -1484,15 +1457,6 @@ version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - [[package]] name = "semver" version = "1.0.18" @@ -1502,12 +1466,6 @@ dependencies = [ "serde", ] -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - [[package]] name = "serde" version = "1.0.175" @@ -1594,21 +1552,6 @@ dependencies = [ "unsafe-libyaml", ] -[[package]] -name = "sha1" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1da05c97445caa12d05e848c4a4fcbbea29e748ac28f7e80e9b010392063770" -dependencies = [ - "sha1_smol", -] - -[[package]] -name = "sha1_smol" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" - [[package]] name = "sha2" version = "0.9.9" @@ -1688,64 +1631,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" -[[package]] -name = "standback" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e113fb6f3de07a243d434a56ec6f186dfd51cb08448239fe7bcae73f87ff28ff" -dependencies = [ - "version_check", -] - -[[package]] -name = "stdweb" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5" -dependencies = [ - "discard", - "rustc_version 0.2.3", - "stdweb-derive", - "stdweb-internal-macros", - "stdweb-internal-runtime", - "wasm-bindgen", -] - -[[package]] -name = "stdweb-derive" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" -dependencies = [ - "proc-macro2", - "quote", - "serde", - "serde_derive", - "syn 1.0.109", -] - -[[package]] -name = "stdweb-internal-macros" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" -dependencies = [ - "base-x", - "proc-macro2", - "quote", - "serde", - "serde_derive", - "serde_json", - "sha1", - "syn 1.0.109", -] - -[[package]] -name = "stdweb-internal-runtime" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" - [[package]] name = "strsim" version = "0.10.0" @@ -1861,40 +1746,30 @@ dependencies = [ [[package]] name = "time" -version = "0.2.27" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4752a97f8eebd6854ff91f1c1824cd6160626ac4bd44287f7f4ea2035a02a242" +checksum = "b0fdd63d58b18d663fbdf70e049f00a22c8e42be082203be7f26589213cd75ea" dependencies = [ - "const_fn", - "libc", - "standback", - "stdweb", + "deranged", + "itoa", + "serde", + "time-core", "time-macros", - "version_check", - "winapi", ] [[package]] -name = "time-macros" +name = "time-core" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957e9c6e26f12cb6d0dd7fc776bb67a706312e7299aed74c8dd5b17ebb27e2f1" -dependencies = [ - "proc-macro-hack", - "time-macros-impl", -] +checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" [[package]] -name = "time-macros-impl" -version = "0.1.2" +name = "time-macros" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd3c141a1b43194f3f56a1411225df8646c55781d5f26db825b3d98507eb482f" +checksum = "eb71511c991639bb078fd5bf97757e03914361c48100d52878b8e52b46fb92cd" dependencies = [ - "proc-macro-hack", - "proc-macro2", - "quote", - "standback", - "syn 1.0.109", + "time-core", ] [[package]] @@ -2513,7 +2388,7 @@ dependencies = [ "anyhow", "derive_builder", "indexmap 1.9.3", - "semver 1.0.18", + "semver", "serde", "serde_cbor", "serde_json", @@ -2587,7 +2462,7 @@ dependencies = [ "petgraph", "pin-project", "rand", - "semver 1.0.18", + "semver", "serde", "serde_cbor", "serde_derive", @@ -2742,7 +2617,7 @@ dependencies = [ "once_cell", "path-clean", "rand", - "semver 1.0.18", + "semver", "serde", "serde_cbor", "serde_json",