3 unstable releases
0.2.0 | Dec 25, 2024 |
---|---|
0.1.1 | Dec 25, 2024 |
0.1.0 | Dec 24, 2024 |
#150 in Date and time
375 downloads per month
Used in 2 crates
14KB
278 lines
Duration Flex
Helper class to make it easier to specify durations. Specially useful in configuration files.
It is common for durations to be specified in configuration files as "the number of seconds", which might not be very readable in some cases.
This crate aims to help solving this problem by allowing the time unit to be specified alongside the amount of time.
Example:
- 1 hour and 23 minutes:
1h23m
- 1 week, 6 days, 23 hours, 49 minutes andd 50 seconds:
1w6d23h49m59s
Usage
Simply call one of the from
methods to create an instance:
use duration_flex::DurationFlex;
pub fn main() {
let df = DurationFlex::try_from("1w6d23h49m59s").unwrap();
println!("{df}");
}
Features
clap
: enable clap support, so it can be used as application arguments.serde
: enable serde support.
Dependencies
~3–4.5MB
~79K SLoC