diff options
author | Felipe Baltor <fbaltor@gmail.com> | 2024-05-23 08:59:11 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-23 13:59:11 +0200 |
commit | fa1ba256d20236042455abb31a92d2a1d27ee58f (patch) | |
tree | cd81e32852e4762f38fffb29ce462f09eab0f0e9 /ext/kv | |
parent | fa273509771c01d603d403002481bc1d01e4dd8b (diff) |
refactor: remove custom `utc_now` in favor of `chrono::Utc:now` feature (#23888)
This PR removes the use of the custom `utc_now` function in favor of the
`chrono` implementation. It resolves #22864.
---------
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Diffstat (limited to 'ext/kv')
-rw-r--r-- | ext/kv/Cargo.toml | 2 | ||||
-rw-r--r-- | ext/kv/lib.rs | 4 | ||||
-rw-r--r-- | ext/kv/time.rs | 15 |
3 files changed, 2 insertions, 19 deletions
diff --git a/ext/kv/Cargo.toml b/ext/kv/Cargo.toml index 12a0e2c90..7349d5841 100644 --- a/ext/kv/Cargo.toml +++ b/ext/kv/Cargo.toml @@ -17,7 +17,7 @@ path = "lib.rs" anyhow.workspace = true async-trait.workspace = true base64.workspace = true -chrono.workspace = true +chrono = { workspace = true, features = ["now"] } deno_core.workspace = true deno_fetch.workspace = true deno_node.workspace = true diff --git a/ext/kv/lib.rs b/ext/kv/lib.rs index 72e1cab30..285614389 100644 --- a/ext/kv/lib.rs +++ b/ext/kv/lib.rs @@ -4,7 +4,6 @@ pub mod dynamic; mod interface; pub mod remote; pub mod sqlite; -mod time; use std::borrow::Cow; use std::cell::RefCell; @@ -56,7 +55,6 @@ use denokv_proto::WatchStream; use log::debug; use serde::Deserialize; use serde::Serialize; -use time::utc_now; pub use crate::interface::*; @@ -772,7 +770,7 @@ async fn op_kv_atomic_write<DBH>( where DBH: DatabaseHandler + 'static, { - let current_timestamp = utc_now(); + let current_timestamp = chrono::Utc::now(); let db = { let state = state.borrow(); let resource = diff --git a/ext/kv/time.rs b/ext/kv/time.rs deleted file mode 100644 index 3a5565332..000000000 --- a/ext/kv/time.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. - -/// Identical to chrono::Utc::now() but without the system "clock" -/// feature flag. -/// -/// The "clock" feature flag pulls in the "iana-time-zone" crate -/// which links to macOS's "CoreFoundation" framework which increases -/// startup time for the CLI. -pub fn utc_now() -> chrono::DateTime<chrono::Utc> { - let now = std::time::SystemTime::now() - .duration_since(std::time::UNIX_EPOCH) - .expect("system time before Unix epoch"); - chrono::DateTime::from_timestamp(now.as_secs() as i64, now.subsec_nanos()) - .unwrap() -} |