Expand description
A tiny Rust library that converts various time formats to milliseconds.
This library provides functionality to parse time strings into milliseconds and format milliseconds into human-readable time strings.
§Examples
use millis::{ms, parse, format, Options};
// Parse time strings
let milliseconds = ms("2h").unwrap();
assert_eq!(milliseconds, 7200000);
let milliseconds = ms("1d").unwrap();
assert_eq!(milliseconds, 86400000);
// Format milliseconds
let formatted = ms(60000).unwrap();
assert_eq!(formatted, "1m");
// With long format - use format() function
let formatted = format(60000, Some(Options { long: true }));
assert_eq!(formatted, "1 minute");Structs§
- Options
- Options for formatting milliseconds
Traits§
- ToMillis
- Trait for types that can be converted to/from milliseconds
Functions§
- format
- Format the given milliseconds as a string.
- ms
- Parse or format the given value.
- parse
- Parse the given string and return milliseconds.
- parse_
strict - Parse the given string and return milliseconds (strict version).