pub mod display_hint;
pub mod hex;
pub mod hints;
#[must_use]
pub fn format_timeticks(centiseconds: u32) -> String {
let total_seconds = centiseconds / 100;
let cs = centiseconds % 100;
let days = total_seconds / 86400;
let hours = (total_seconds % 86400) / 3600;
let minutes = (total_seconds % 3600) / 60;
let seconds = total_seconds % 60;
if days > 0 {
format!("{days}d {hours:02}:{minutes:02}:{seconds:02}.{cs:02}")
} else {
format!("{hours:02}:{minutes:02}:{seconds:02}.{cs:02}")
}
}
#[must_use]
pub fn format_hex_display(bytes: &[u8]) -> String {
bytes
.iter()
.map(|b| format!("{b:02X}"))
.collect::<Vec<_>>()
.join(" ")
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_format_timeticks() {
assert_eq!(format_timeticks(1234_5678), "1d 10:17:36.78");
assert_eq!(format_timeticks(360_000), "01:00:00.00");
assert_eq!(format_timeticks(0), "00:00:00.00");
}
#[test]
fn test_format_hex_display() {
assert_eq!(format_hex_display(&[0x00, 0x1A, 0x2B]), "00 1A 2B");
assert_eq!(format_hex_display(&[]), "");
}
}