Format a millisecond timestamp into a readable string.
(ms: i64)
| 7821 | |
| 7822 | /// Format a millisecond timestamp into a readable string. |
| 7823 | fn format_timestamp_ms(ms: i64) -> String { |
| 7824 | if ms <= 0 { |
| 7825 | return "-".to_string(); |
| 7826 | } |
| 7827 | let secs = ms / 1000; |
| 7828 | let mins = (secs / 60) % 60; |
| 7829 | let hours = (secs / 3600) % 24; |
| 7830 | let days = secs / 86400; |
| 7831 | if days > 0 { |
| 7832 | format!("{days}d {hours:02}:{mins:02}") |
| 7833 | } else { |
| 7834 | format!("{hours:02}:{mins:02}") |
| 7835 | } |
| 7836 | } |
| 7837 | |
| 7838 | #[cfg(test)] |
| 7839 | mod tests { |
nothing calls this directly
no outgoing calls
no test coverage detected