human-duration 0.1.0

human-duration converts a std::time::Duration to a human readable string.
Documentation
  • Coverage
  • 100%
    2 out of 2 items documented2 out of 2 items with examples
  • Size
  • Source code size: 25.72 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.07 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • cars10/human-duration
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • cars10

human-duration

Crates.io Crates.io docs.rs

human-duration converts a std::time::Duration to a human readable string.

Examples

use human_duration::human_duration;

let duration = std::time::Duration::new(120, 30_000_000);
assert_eq!(human_duration(&duration), "2m 0s 30ms");

let duration = std::time::Duration::new(9000, 0);
assert_eq!(human_duration(&duration), "2h 30m 0s 0ms");

Usage

Run

cargo add human_duration

or manually add it to your Cargo.toml:

[dependencies]
human_duration = "0.1"

Then use the human_duration function:

use human_duration::human_duration;

// somewhere in your code:
let duration = std::time::Duration::new(120, 0);
println!(human_duration(&duration));

License

MIT