You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
430 B
Rust
14 lines
430 B
Rust
use chrono::NaiveDateTime;
|
|
use std::time::{SystemTime, UNIX_EPOCH};
|
|
|
|
/// Converts a system time timestamp to a NaiveDateTime object
|
|
pub fn system_time_to_naive_date_time(system_time: SystemTime) -> NaiveDateTime {
|
|
let epoch_duration = system_time.duration_since(UNIX_EPOCH).unwrap();
|
|
|
|
NaiveDateTime::from_timestamp_opt(
|
|
epoch_duration.as_secs() as i64,
|
|
epoch_duration.subsec_nanos(),
|
|
)
|
|
.unwrap()
|
|
}
|