Skip to content

Commit

Permalink
stats and sniff: with chrono 0.4.27, DateTime::from_utc has been …
Browse files Browse the repository at this point in the history
…deprecated

replace with DateTime::from_native_utc_and_offset
  • Loading branch information
jqnatividad committed Aug 30, 2023
1 parent 2d24ee2 commit 719a089
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/cmd/sniff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<chrono::Utc>::from_utc(naive, chrono::Utc);
let datetime = chrono::DateTime::<chrono::Utc>::from_naive_utc_and_offset(
naive,
chrono::Utc,
);
// format the datetime to RFC3339
format!("{datetime}", datetime = datetime.format("%+"))
},
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Utc>::from_utc(
let date_val = DateTime::<Utc>::from_naive_utc_and_offset(
NaiveDateTime::from_timestamp_millis(timestamp).unwrap_or_default(),
Utc,
)
Expand Down

0 comments on commit 719a089

Please sign in to comment.