Update chrono & clap dependencies
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@ -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<Utc> = 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()
|
||||
|
Reference in New Issue
Block a user