#tiny #conversion #version #utility #milisecond

ms

A Rust version of Tiny milisecond conversion utility

2 releases

0.1.1 Mar 8, 2019
0.1.0 Mar 8, 2019

#452 in Date and time

Download history 22/week @ 2024-04-08 22/week @ 2024-04-15 47/week @ 2024-04-22 24/week @ 2024-04-29 23/week @ 2024-05-06 30/week @ 2024-05-13 27/week @ 2024-05-20 24/week @ 2024-05-27 23/week @ 2024-06-03 27/week @ 2024-06-10 22/week @ 2024-06-17 32/week @ 2024-06-24 9/week @ 2024-07-01 25/week @ 2024-07-08 23/week @ 2024-07-15 24/week @ 2024-07-22

85 downloads per month
Used in hop-cli

MIT license

6KB
104 lines

ms

A Rust version of Tiny milisecond conversion utility

Install

Cargo.toml

[dependencies]
ms = "0.1.0"

Usage

extern crate ms;
use ms::*;

fn main() {
    ms!("2 days");  // 172800000
    ms!("1d");      // 86400000
    ms!("10h");     // 36000000
    ms!("2.5 hrs"); // 9000000
    ms!("2h");      // 7200000
    ms!("1m");      // 60000
    ms!("5s");      // 5000
    ms!("1y");      // 31557600000
    ms!("100");     // 100

    // convert in milliseconds to string in short type
    ms!(60000, false);        // "1m"
    ms!(2*60000, false);      // "2m"
    ms!(ms!("10 hours"), false); // "10h"

    // convert in milliseconds to string in long type
    ms!(60000, true);         // "1 minute"
    ms!(2*60000, true);       // "2 minutes"
    ms!(ms!("10 hours"), true);  // "10 hours"
}

Test

$ cargo test

Dependencies

~2.2–3MB
~53K SLoC