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

no-std human_readable_duration

A Rust library for formatting and parsing human-readable durations

2 releases

new 0.1.2 Oct 31, 2024
0.1.1 Oct 29, 2024

#190 in No standard library

Download history 68/week @ 2024-10-24

68 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

Ben Santora (bensatlantik@gmail.com)

No runtime deps