diff --git a/src/tools.rs b/src/tools.rs index feb5dae..4a7a4ce 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -1,5 +1,6 @@ use std::net::{IpAddr, Ipv4Addr, SocketAddr, ToSocketAddrs}; -use chrono::{DateTime,Utc,NaiveDateTime}; +use chrono::NaiveDateTime; +//use chrono::{DateTime,Local, Utc,NaiveDateTime}; //use std::time::{UNIX_EPOCH, Duration}; pub fn get_socket_addr(bind: &str, port: u16) -> SocketAddr { @@ -49,10 +50,18 @@ pub fn path_timestamp(filepath: &str) -> u32 { pub fn str_date_from_timestamp(timestamp: &str) -> String { if timestamp.is_empty() { return String::from(""); } let val: i64 = timestamp.parse().unwrap_or_default(); - let dt = NaiveDateTime::from_timestamp_opt(val, 0).unwrap_or_default(); - let datetime = DateTime::::from_utc(dt, Utc); + let datetime = NaiveDateTime::from_timestamp_opt(val, 0).unwrap_or_default(); // (Local::now()); + /* + let naive_utc = dt.naive_utc(); + let offset = dt.offset().clone(); + // Serialize, pass through FFI... and recreate the `DateTime`: + let datetime = DateTime::::from_naive_utc_and_offset(naive_utc, offset); + + // let datetime = DateTime::::from_ut(dt, Utc); + // let val = u64::try_from(timestamp.to_owned()).unwrap_or_default(); // let str_timestamp = UNIX_EPOCH + Duration::from_millis(val); // let datetime = DateTime::::from(str_timestamp); + */ datetime.format("%Y-%m-%d %H:%M:%S").to_string() }