From 90b025cd10addf79addb4ed3ccd5bed8abfdf748 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 17 Jan 2024 16:47:35 +0000 Subject: [PATCH] Bump chrono from 0.4.26 to 0.4.31 (#117) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 30 ++++++------------------------ src/configuration/mod.rs | 10 +++++++--- src/location/aprs.rs | 4 ++-- src/utilities.rs | 14 ++++++-------- 4 files changed, 21 insertions(+), 37 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 26839198..24a247a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -223,18 +223,17 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.26" +version = "0.4.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", "serde", - "time 0.1.45", "wasm-bindgen", - "winapi", + "windows-targets 0.48.0", ] [[package]] @@ -654,7 +653,7 @@ checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" dependencies = [ "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", ] [[package]] @@ -1044,7 +1043,7 @@ checksum = "eebffdb73fe72e917997fad08bdbf31ac50b0fa91cec93e69a0662e4264d454c" dependencies = [ "libc", "log", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "windows-sys 0.48.0", ] @@ -1583,7 +1582,7 @@ dependencies = [ "serde", "serde_json", "serde_with_macros", - "time 0.3.21", + "time", ] [[package]] @@ -1819,17 +1818,6 @@ dependencies = [ "syn", ] -[[package]] -name = "time" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" -dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi", -] - [[package]] name = "time" version = "0.3.21" @@ -2054,12 +2042,6 @@ dependencies = [ "try-lock", ] -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" diff --git a/src/configuration/mod.rs b/src/configuration/mod.rs index f23399d6..a277cf99 100644 --- a/src/configuration/mod.rs +++ b/src/configuration/mod.rs @@ -183,9 +183,13 @@ mod tests { start: crate::location::Location { coord: geo::coord! { x: -78.4987, y: 40.0157 }, altitude: None, - time: chrono::Local - .datetime_from_str("2022-03-05 10:36:00", &crate::DATETIME_FORMAT) - .unwrap() + time: chrono::NaiveDateTime::parse_from_str( + "2022-03-05 10:36:00", + &crate::DATETIME_FORMAT + ) + .unwrap() + .and_local_timezone(chrono::Local) + .unwrap() }, profile: crate::configuration::prediction::StandardProfile { ascent_rate: 6.5, diff --git a/src/location/aprs.rs b/src/location/aprs.rs index 594281a9..82bec62b 100644 --- a/src/location/aprs.rs +++ b/src/location/aprs.rs @@ -99,7 +99,7 @@ impl crate::location::BalloonLocation { naive_packet_time = now.naive_utc(); } } - packet_time = chrono::DateTime::::from_utc( + packet_time = chrono::DateTime::::from_naive_utc_and_offset( naive_packet_time, chrono::Utc, ) @@ -289,7 +289,7 @@ mod tests { assert_eq!( packet.location.time, - chrono::DateTime::::from_utc( + chrono::DateTime::::from_naive_utc_and_offset( chrono::Utc::now() .date_naive() .and_hms_opt(7, 48, 49) diff --git a/src/utilities.rs b/src/utilities.rs index 64b2a1a2..e1c697da 100644 --- a/src/utilities.rs +++ b/src/utilities.rs @@ -4,7 +4,6 @@ pub fn approx_equal(a: f64, b: f64, decimal_precision: u8) -> bool { } pub mod optional_local_datetime_string { - use chrono::TimeZone; use serde::Deserialize; const FORMAT: &str = "%Y-%m-%d %H:%M:%S"; @@ -32,8 +31,8 @@ pub mod optional_local_datetime_string { if let Some(value) = value { return Ok(Some(match chrono::DateTime::parse_from_rfc3339(&value) { Ok(datetime) => datetime.with_timezone(&chrono::Local), - Err(_) => match chrono::Local.datetime_from_str(&value, FORMAT) { - Ok(datetime) => datetime, + Err(_) => match chrono::NaiveDateTime::parse_from_str(&value, FORMAT) { + Ok(datetime) => datetime.and_local_timezone(chrono::Local).unwrap(), Err(_) => chrono::NaiveDate::parse_from_str(&value, "%Y-%m-%d") .map_err(serde::de::Error::custom)? .and_hms_opt(0, 0, 0) @@ -49,7 +48,6 @@ pub mod optional_local_datetime_string { } pub mod local_datetime_string { - use chrono::TimeZone; use serde::Deserialize; const FORMAT: &str = "%Y-%m-%d %H:%M:%S"; @@ -72,10 +70,10 @@ pub mod local_datetime_string { let value: String = String::deserialize(deserializer)?; Ok(match chrono::DateTime::parse_from_rfc3339(&value) { Ok(datetime) => datetime.with_timezone(&chrono::Local), - Err(_) => match chrono::DateTime::parse_from_str(&value, "%Y-%m-%d %H:%M:%S %Z") { - Ok(datetime) => datetime.with_timezone(&chrono::Local), - Err(_) => match chrono::Local.datetime_from_str(&value, FORMAT) { - Ok(datetime) => datetime, + Err(_) => match chrono::NaiveDateTime::parse_from_str(&value, "%Y-%m-%d %H:%M:%S %Z") { + Ok(datetime) => datetime.and_local_timezone(chrono::Local).unwrap(), + Err(_) => match chrono::NaiveDateTime::parse_from_str(&value, FORMAT) { + Ok(datetime) => datetime.and_local_timezone(chrono::Local).unwrap(), Err(_) => chrono::NaiveDate::parse_from_str(&value, "%Y-%m-%d") .map_err(serde::de::Error::custom)? .and_hms_opt(0, 0, 0)