From 06766a2af42ad6ac179f1402e2a159fb831f9fff Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 15 Mar 2024 16:39:17 +0100 Subject: [PATCH] Update chrono & clap dependencies --- Cargo.lock | 16 ++++++++-------- Cargo.toml | 6 +++--- src/utils/time.rs | 11 ++++------- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 967593f..58035f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -792,9 +792,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.34" +version = "0.4.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bc015644b92d5890fab7489e49d21f879d5c990186827d42ec511919404f38b" +checksum = "8eaf5903dcbc0a39312feb77df2ff4c76387d591b9fc7b04a238dcf8bb62639a" dependencies = [ "android-tzdata", "iana-time-zone", @@ -816,9 +816,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.2" +version = "4.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b230ab84b0ffdf890d5a10abdbc8b83ae1c4918275daea1ab8801f71536b2651" +checksum = "949626d00e063efc93b6dca932419ceb5432f99769911c0b995f7e884c778813" dependencies = [ "clap_builder", "clap_derive", @@ -838,9 +838,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.0" +version = "4.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47" +checksum = "90239a040c80f5e14809ca132ddc4176ab33d5e17e49691793296e3fcb34d72f" dependencies = [ "heck", "proc-macro2", @@ -1396,9 +1396,9 @@ checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" [[package]] name = "heck" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hex" diff --git a/Cargo.toml b/Cargo.toml index de7f437..412507c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ actix-identity = "0.7.1" actix-web = "4.5.1" actix-session = { version = "0.9.0", features = ["cookie-session"] } actix-remote-ip = "0.1.0" -clap = { version = "4.5.2", features = ["derive", "env"] } +clap = { version = "4.5.3", features = ["derive", "env"] } include_dir = "0.7.3" log = "0.4.21" serde_json = "1.0.114" @@ -37,6 +37,6 @@ webauthn-rs = { version = "0.4.8", features = ["danger-allow-state-serialisation url = "2.5.0" light-openid = { version = "1.0.1", features = ["crypto-wrapper"] } bincode = "2.0.0-rc.3" -chrono = "0.4.34" +chrono = "0.4.35" lazy_static = "1.4.0" -mailchecker = "6.0.1" \ No newline at end of file +mailchecker = "6.0.1" diff --git a/src/utils/time.rs b/src/utils/time.rs index 317c0b1..b757eba 100644 --- a/src/utils/time.rs +++ b/src/utils/time.rs @@ -1,4 +1,4 @@ -use chrono::{DateTime, NaiveDateTime, Utc}; +use chrono::DateTime; use std::time::{SystemTime, UNIX_EPOCH}; /// Get the current time since epoch @@ -11,12 +11,9 @@ pub fn time() -> u64 { /// Format unix timestamp to a human-readable string pub fn fmt_time(timestamp: u64) -> String { - // Create a NaiveDateTime from the timestamp - let naive = - NaiveDateTime::from_timestamp_opt(timestamp as i64, 0).expect("Failed to parse timestamp!"); - - // Create a normal DateTime from the NaiveDateTime - let datetime: DateTime = DateTime::from_naive_utc_and_offset(naive, Utc); + // Create a DateTime from the timestamp + let datetime = + DateTime::from_timestamp(timestamp as i64, 0).expect("Failed to parse timestamp!"); // Format the datetime how you want datetime.format("%Y-%m-%d %H:%M:%S").to_string()