Update Rust crate chrono to 0.4.27 #167

Merged
pierre merged 2 commits from renovate/chrono-0.x into master 2023-08-31 10:05:59 +00:00
3 changed files with 20 additions and 5 deletions

6
Cargo.lock generated
View File

@ -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]]

View File

@ -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"

View File

@ -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<Utc> = DateTime::from_utc(naive, Utc);
let datetime: DateTime<Utc> = 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");
}
}