Update chrono & clap dependencies
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-03-15 16:39:17 +01:00
parent c7302c70d8
commit 06766a2af4
3 changed files with 15 additions and 18 deletions

View File

@ -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()