Format epoch milliseconds as a human-readable UTC timestamp: `YYYY-MM-DD HH:MM`.
(epoch_ms: i64)
| 2482 | |
| 2483 | /// Format epoch milliseconds as a human-readable UTC timestamp: `YYYY-MM-DD HH:MM`. |
| 2484 | fn format_timestamp(epoch_ms: i64) -> String { |
| 2485 | if epoch_ms <= 0 { |
| 2486 | return String::from("-"); |
| 2487 | } |
| 2488 | let secs = epoch_ms / 1000; |
| 2489 | let days = secs / 86400; |
| 2490 | let time_of_day = secs % 86400; |
| 2491 | let hours = time_of_day / 3600; |
| 2492 | let minutes = (time_of_day % 3600) / 60; |
| 2493 | |
| 2494 | let (year, month, day) = days_to_ymd(days); |
| 2495 | format!("{year:04}-{month:02}-{day:02} {hours:02}:{minutes:02}") |
| 2496 | } |
| 2497 | |
| 2498 | /// Convert days since Unix epoch (1970-01-01) to (year, month, day). |
| 2499 | #[allow(clippy::unreadable_literal)] |
no test coverage detected