human-duration converts a std::time::Duration
to a human readable string.
```rust use humanduration::humanduration;
let duration = std::time::Duration::new(120, 30000000); asserteq!(humanduration(&duration), "2m 0s 30ms");
let duration = std::time::Duration::new(9000, 0); asserteq!(humanduration(&duration), "2h 30m 0s 0ms"); ```
Run
bash
cargo add human_duration
or manually add it to your Cargo.toml
:
toml
[dependencies]
human_duration = "0.1"
Then use the human_duration
function:
```rust use humanduration::humanduration;
// somewhere in your code: let duration = std::time::Duration::new(120, 0); println!(human_duration(&duration)); ```
MIT