From 719a08948b3910a909670a18aa8f0f35d98576ae Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Wed, 30 Aug 2023 15:29:30 -0400 Subject: [PATCH] `stats` and `sniff`: with chrono 0.4.27, DateTime::from_utc has been deprecated replace with DateTime::from_native_utc_and_offset --- src/cmd/sniff.rs | 6 ++++-- src/cmd/stats.rs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cmd/sniff.rs b/src/cmd/sniff.rs index 60be58a20..258ad1887 100644 --- a/src/cmd/sniff.rs +++ b/src/cmd/sniff.rs @@ -619,8 +619,10 @@ async fn get_file_to_sniff(args: &Args, tmpdir: &tempfile::TempDir) -> CliResult .as_secs(); let naive = chrono::NaiveDateTime::from_timestamp_opt(timestamp as i64, 0) .unwrap_or_default(); - let datetime = - chrono::DateTime::::from_utc(naive, chrono::Utc); + let datetime = chrono::DateTime::::from_naive_utc_and_offset( + naive, + chrono::Utc, + ); // format the datetime to RFC3339 format!("{datetime}", datetime = datetime.format("%+")) }, diff --git a/src/cmd/stats.rs b/src/cmd/stats.rs index 83e6ac771..2c4bdb393 100644 --- a/src/cmd/stats.rs +++ b/src/cmd/stats.rs @@ -951,7 +951,7 @@ pub struct Stats { fn timestamp_ms_to_rfc3339(timestamp: i64, typ: FieldType) -> String { use chrono::{DateTime, NaiveDateTime, Utc}; - let date_val = DateTime::::from_utc( + let date_val = DateTime::::from_naive_utc_and_offset( NaiveDateTime::from_timestamp_millis(timestamp).unwrap_or_default(), Utc, )