Use this Rust crate to easily parse various time formats to durations.
```rust use dauer::duration; use std::time::Duration;
let nanoseconds = duration("1 nanosecond"); let milliseconds = duration("2 milliseconds"); let seconds = duration("3 seconds"); let minutes = duration("4 minutes"); let hours = duration("5 hours"); let day = duration("6 days"); let week = duration("7 weeks"); let month = duration("8 months"); let year = duration("9 months"); let realbigduration = duration("9 years, 8 months, 7 weeks and 6 days"); let realsmallduration = duration("4 minutes 3 seconds, 2 milliseconds and 1 nanosecond"); ```
duration
function provides straight forward functions to parse durations from a human-readable format, into std::time::Duration instances.years
: returns the parsed duration as an amount of yearsmonths
: returns the parsed duration as an amount of monthsweeks
: returns the parsed duration as an amount of weeksdays
: returns the parsed duration as an amount of dayshours
: returns the parsed duration as an amount of hoursminutes
: returns the parsed duration as an amount of minutesseconds
: returns the parsed duration as an amount of secondsmilliseconds
: returns the parsed duration as an amount of yearsnanoseconds
: returns the parsed duration as an amount of yearsAdd it as a dependency to your Cargo.toml
toml
[dependencies]
jackdauer = "0.1.0"
"Dauer" is the German word for duration. When thinking about time, it reminded me of this show called "24", and its main character "Jack Bauer" (which, incidentally also happens to mean "builder" in German). The contraction of both gives "Jack Dauer".
It's 2021, COVID-19 is still raging out there. The last year and a half has been quite gloomy, and I thought I needed (and you needed too; maybe you're not just aware of it) of some terrible pun to shed some light on my day to day quarantined life.