#duration #human-readable #formatting #time #parser

no-std human_readable_duration

A Rust library for formatting and parsing human-readable durations

3 releases

new 0.1.3 Nov 21, 2024
0.1.2 Oct 31, 2024
0.1.1 Oct 29, 2024

#147 in No standard library

Download history 105/week @ 2024-10-24 170/week @ 2024-10-31 10/week @ 2024-11-07

285 downloads per month

MIT license

4KB

Installation

Add human_readable_duration to your Cargo.toml dependencies:

[dependencies] human_readable_duration = "0.1.0"

Usage

The following example demonstrates how to use the format_duration function with the Duration type:

use human_readable_duration::format_duration;
use std::time::Duration;

fn main() {
    let duration = Duration::new(93784, 0); // 1 day, 2 hours, 3 minutes, 4 seconds
    println!("{}", format_duration(duration)); 
    // Outputs: "1 day, 2 hours, 3 minutes, 4 seconds"
}

License

This project is licensed under the MIT License. See the LICENSE file for details.

Author

bensatlantik

No runtime deps