summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorFelipe Baltor <fbaltor@gmail.com>2024-05-23 08:59:11 -0300
committerGitHub <noreply@github.com>2024-05-23 13:59:11 +0200
commitfa1ba256d20236042455abb31a92d2a1d27ee58f (patch)
treecd81e32852e4762f38fffb29ce462f09eab0f0e9 /cli
parentfa273509771c01d603d403002481bc1d01e4dd8b (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 'cli')
-rw-r--r--cli/Cargo.toml2
-rw-r--r--cli/bench/main.rs5
-rw-r--r--cli/tools/coverage/reporter.rs2
-rw-r--r--cli/tools/upgrade.rs5
-rw-r--r--cli/util/mod.rs1
-rw-r--r--cli/util/time.rs19
6 files changed, 6 insertions, 28 deletions
diff --git a/cli/Cargo.toml b/cli/Cargo.toml
index 9c8c4f6bd..c2edd2b60 100644
--- a/cli/Cargo.toml
+++ b/cli/Cargo.toml
@@ -86,7 +86,7 @@ base64.workspace = true
bincode = "=1.3.3"
bytes.workspace = true
cache_control.workspace = true
-chrono.workspace = true
+chrono = { workspace = true, features = ["now"] }
clap = { version = "=4.4.17", features = ["env", "string"] }
clap_complete = "=4.4.7"
clap_complete_fig = "=4.4.2"
diff --git a/cli/bench/main.rs b/cli/bench/main.rs
index 8f0627558..cfbc44e8c 100644
--- a/cli/bench/main.rs
+++ b/cli/bench/main.rs
@@ -17,8 +17,6 @@ use std::process::Stdio;
use std::time::SystemTime;
use test_util::PathRef;
-include!("../util/time.rs");
-
mod http;
mod lsp;
@@ -442,7 +440,8 @@ async fn main() -> Result<()> {
env::set_current_dir(test_util::root_path())?;
let mut new_data = BenchResult {
- created_at: utc_now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true),
+ created_at: chrono::Utc::now()
+ .to_rfc3339_opts(chrono::SecondsFormat::Secs, true),
sha1: test_util::run_collect(
&["git", "rev-parse", "HEAD"],
None,
diff --git a/cli/tools/coverage/reporter.rs b/cli/tools/coverage/reporter.rs
index f359755a9..4bb72b264 100644
--- a/cli/tools/coverage/reporter.rs
+++ b/cli/tools/coverage/reporter.rs
@@ -399,7 +399,7 @@ impl CoverageReporter for HtmlCoverageReporter {
fn done(&mut self, coverage_root: &Path) {
let summary = self.collect_summary(&self.file_reports);
- let now = crate::util::time::utc_now().to_rfc2822();
+ let now = chrono::Utc::now().to_rfc2822();
for (node, stats) in &summary {
let report_path =
diff --git a/cli/tools/upgrade.rs b/cli/tools/upgrade.rs
index 073ebdc1c..8379c6fd2 100644
--- a/cli/tools/upgrade.rs
+++ b/cli/tools/upgrade.rs
@@ -10,7 +10,6 @@ use crate::http_util::HttpClient;
use crate::standalone::binary::unpack_into_dir;
use crate::util::progress_bar::ProgressBar;
use crate::util::progress_bar::ProgressBarStyle;
-use crate::util::time;
use crate::version;
use async_trait::async_trait;
@@ -60,7 +59,7 @@ impl RealUpdateCheckerEnvironment {
Self {
cache_file_path,
// cache the current time
- current_time: time::utc_now(),
+ current_time: chrono::Utc::now(),
}
}
}
@@ -785,7 +784,7 @@ mod test {
current_version: Default::default(),
is_canary: Default::default(),
latest_version: Rc::new(RefCell::new(Ok("".to_string()))),
- time: Rc::new(RefCell::new(crate::util::time::utc_now())),
+ time: Rc::new(RefCell::new(chrono::Utc::now())),
}
}
diff --git a/cli/util/mod.rs b/cli/util/mod.rs
index c8155dc51..89df7bb98 100644
--- a/cli/util/mod.rs
+++ b/cli/util/mod.rs
@@ -15,7 +15,6 @@ pub mod progress_bar;
pub mod result;
pub mod sync;
pub mod text_encoding;
-pub mod time;
pub mod unix;
pub mod v8;
pub mod windows;
diff --git a/cli/util/time.rs b/cli/util/time.rs
deleted file mode 100644
index 47306c126..000000000
--- a/cli/util/time.rs
+++ /dev/null
@@ -1,19 +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.
-///
-/// You can simply include this file in your project using
-/// `include!("path/to/cli/util/time.rs"))` and use it
-/// as a drop-in replacement for chrono::Utc::now().
-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()
-}