#date-time #milliseconds #parser #pretty-millisecond #pretty-ms #pretty-date

no-std millisecond

Format milliseconds into a human-readable format. It also, parse a milliseonds into its core parts, including years, days, hours, etc. This package has no-std dependency.

5 unstable releases

0.3.0 Sep 17, 2024
0.2.2 Sep 16, 2024
0.2.1 Jun 29, 2024
0.2.0 Jun 28, 2024
0.1.0 Jun 27, 2024

#190 in Date and time

Download history 97/week @ 2024-09-25 97/week @ 2024-10-02 89/week @ 2024-10-09 80/week @ 2024-10-16 81/week @ 2024-10-23 83/week @ 2024-10-30 87/week @ 2024-11-06 84/week @ 2024-11-13 86/week @ 2024-11-20 83/week @ 2024-11-27 84/week @ 2024-12-04 94/week @ 2024-12-11 76/week @ 2024-12-18 58/week @ 2024-12-25 69/week @ 2025-01-01 77/week @ 2025-01-08

293 downloads per month

MIT license

27KB
688 lines

Millisecond crate

A better way to format and display time, which converts 33023448000ms to 1y 17d 5h 10m 48s

Install

In your Rust project root directory run:

$ cargo add millisecond

Example

use millisecond::Millisecond;

fn main() {
    let ms = Millisecond::from_millis(33023448000);

    print!("display: {ms}");
    // display: 1y 17d 5h 10m 48s

    print!("short: {}", ms.to_short_string());
    // short: 1y 17d 5h 10m 48s

    print!("long: {}", ms.to_long_string());
    // long: 1 year 17 days 5 hours 10 minutes 48 seconds

    assert_eq!(ms, Millisecond {
        years: 1,
        days: 17,
        hours: 5,
        minutes: 10,
        seconds: 48,
        millis: 0,
        micros: 0,
        nanos: 0,
    });
}

License

MIT

Inspiration

This crate is inspired by pretty-ms npm package.


lib.rs:

githubcrates-iodocs-rs

A better way to format and display time. This crate converts 33023448000 to 1y 17d 5h 10m 48s

No runtime deps