jackdauer

Crates.iojackdauer
lib.rsjackdauer
version0.1.2
sourcesrc
created_at2021-07-25 16:00:05.135471
updated_at2023-04-24 10:56:11.086865
descriptionUse this Rust crate to easily parse various time formats to durations
homepagehttps://github.com/oleiade/jackdauer#readme
repositoryhttps://github.com/oleiade/jackdauer
max_upload_size
id427104
size53,458
Théo Crevon (oleiade)

documentation

README

JackDauer

CI

Use this Rust crate to easily parse various time formats to durations.

Demo

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 real_big_duration = duration("9 years, 8 months, 7 weeks and 6 days");
let real_small_duration = duration("4 minutes 3 seconds, 2 milliseconds and 1 nanosecond");

Features

  • The duration function provides straightforward functions to parse durations from a human-readable format, into std::time::Duration instances.
  • The time unit-specific functions return unsigned integers representing the amount of said time unit parsed from a human-readable format:
    • years returns the parsed duration as a number of years
    • months returns the parsed duration as a number of months
    • weeks returns the parsed duration as a number of weeks
    • days returns the parsed duration as a number of days
    • hours returns the parsed duration as a number of hours
    • minutes returns the parsed duration as a number of minutes
    • seconds returns the parsed duration as a number of seconds
    • milliseconds returns the parsed duration as a number of years
    • nanoseconds returns the parsed duration as a number of years

Installation

Add it as a dependency to your Cargo.toml

[dependencies]
jackdauer = "0.1.0"

Documentation

Documentation

Authors

FAQ

What's the name about?

"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".

But why the ridiculous name?

It's 2021, COVID-19 is still raging out there. The last year and a half have been quite gloomy, and I thought I needed (and you probably needed it too; maybe you're not just aware of it) some terrible pun to shed some light on my day-to-day quarantined life.

Acknowledgements

License

MIT

Commit count: 17

cargo fmt