pub fn parse(s: &str) -> Result<i64, String>Expand description
Parse the given string and return milliseconds.
§Arguments
s- A string to parse to milliseconds (e.g., “2h”, “1d”, “10 seconds”)
§Returns
The parsed value in milliseconds as i64, or an error for invalid inputs.
§Note
Values are rounded to the nearest integer millisecond.
§Examples
use millis::parse;
assert_eq!(parse("2h").unwrap(), 7200000);
assert_eq!(parse("1 day").unwrap(), 86400000);
assert_eq!(parse("30 minutes").unwrap(), 1800000);
assert_eq!(parse("-1h").unwrap(), -3600000);
assert!(parse("invalid").is_err());