5 unstable releases
new 0.3.1 | May 7, 2025 |
---|---|
0.3.0 |
|
0.2.0 | Mar 31, 2024 |
0.1.2 | Mar 31, 2024 |
#915 in Parser implementations
71KB
1.5K
SLoC
systemd-duration is a library that parses systemd-style durations.
It can parse durations into the following formats:
time::Duration
(with thewith-time
feature)chrono::TimeDelta
(with thewith-chrono
feature)std::time::Duration
It uses the [nom
] library to parse durations.
Example
let td = systemd_duration::stdtime::parse("1d3s").expect("Could not parse duration");
assert_eq!(td, std::time::Duration::from_secs(86_403));
systemd-duration
systemd-duration
is a crate that implements parsing of the systemd duration format in Rust.
This library can convert a systemd duration string to the following:
- std::time::Duration
- time::Duration (available with the
with-time
feature) - chrono::TimeDelta (available with the
with-chrono
feature)
Usage
See the examples directory for code examples.
Dependencies
~1–2MB
~40K SLoC