Crates.io | ms |
lib.rs | ms |
version | 0.1.1 |
source | src |
created_at | 2019-03-08 03:43:19.974161 |
updated_at | 2019-03-08 04:02:00.221144 |
description | A Rust version of Tiny milisecond conversion utility |
homepage | https://github.com/nesso99/ms-rust |
repository | https://github.com/nesso99/ms-rust |
max_upload_size | |
id | 119425 |
size | 8,443 |
A Rust version of Tiny milisecond conversion utility
Cargo.toml
[dependencies]
ms = "0.1.0"
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"
}
$ cargo test