lssa/explorer_service/src/format_utils.rs

13 lines
444 B
Rust
Raw Normal View History

2026-01-28 03:21:43 +03:00
//! Formatting utilities for the explorer
/// Format timestamp to human-readable string
pub fn format_timestamp(timestamp: u64) -> String {
let seconds = timestamp / 1000;
2026-03-03 23:21:08 +03:00
let datetime = chrono::DateTime::from_timestamp(
i64::try_from(seconds).expect("Timestamp out of range"),
0,
)
.unwrap_or_else(|| chrono::DateTime::from_timestamp(0, 0).unwrap());
2026-01-28 03:21:43 +03:00
datetime.format("%Y-%m-%d %H:%M:%S UTC").to_string()
}