parse-duration-rs is a Rust port of Golang parse duration time.ParseDuration
.
It parses a duration string in a short form such as 100ms
, 1h45m
, and 3ns
and return duration in nanoseconds.
The crate is called go-parse-duration
and you can depend on it via cargo:
ini
[dependencies]
go-parse-duration = "0.1"
```rust use goparseduration::{parse_duration, Error};
fn parse() -> Result
Usage with Chrono
Converting to Chrono duration can be done easily:
```rust use chrono::Duration; use goparseduration::{parse_duration, Error};
fn parse() -> Result
Armin Primadi https://github.com/aprimadi (@ Sahamee)