From cc7ae906f14b6eed0d6aaaaece07b56649d5e0ea Mon Sep 17 00:00:00 2001 From: Pierre Hubert Date: Wed, 30 Aug 2023 00:23:11 +0000 Subject: [PATCH 1/2] Update Rust crate chrono to 0.4.27 --- Cargo.lock | 6 +++--- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bc65833..30e76fa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -739,9 +739,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.26" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +checksum = "f56b4c72906975ca04becb8a30e102dfecddd0c06181e3e95ddc444be28881f8" dependencies = [ "android-tzdata", "iana-time-zone", @@ -749,7 +749,7 @@ dependencies = [ "num-traits", "time 0.1.45", "wasm-bindgen", - "winapi", + "windows-targets 0.48.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 46b849e..f3a9cb1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,5 +37,5 @@ webauthn-rs = { version = "0.4.8", features = ["danger-allow-state-serialisation url = "2.4.1" light-openid = { version = "1.0.1", features=["crypto-wrapper"] } bincode = "2.0.0-rc.3" -chrono = "0.4.26" +chrono = "0.4.27" lazy_static = "1.4.0" \ No newline at end of file -- 2.47.2 From 634ba78bf93e011b882a6d45c5df4088cfca5c0d Mon Sep 17 00:00:00 2001 From: Pierre Hubert Date: Thu, 31 Aug 2023 11:59:00 +0200 Subject: [PATCH 2/2] Fix update issue --- src/utils/time.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/utils/time.rs b/src/utils/time.rs index 5eb474d..317c0b1 100644 --- a/src/utils/time.rs +++ b/src/utils/time.rs @@ -16,8 +16,23 @@ pub fn fmt_time(timestamp: u64) -> String { 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_utc(naive, Utc); + let datetime: DateTime = DateTime::from_naive_utc_and_offset(naive, Utc); // Format the datetime how you want datetime.format("%Y-%m-%d %H:%M:%S").to_string() } + +#[cfg(test)] +mod test { + use crate::utils::time::{fmt_time, time}; + + #[test] + fn test_time() { + assert!(time() > 10); + } + + #[test] + fn test_fmt_time() { + assert_eq!(fmt_time(1693475465), "2023-08-31 09:51:05"); + } +} -- 2.47.2