#duration #time #systemd #format

systemd-duration

Convert systemd style time durations into other formats

5 unstable releases

new 0.3.1 May 7, 2025
0.3.0 May 7, 2025
0.2.0 Mar 31, 2024
0.1.2 Mar 31, 2024

#915 in Parser implementations

CC0 license

71KB
1.5K SLoC

systemd-duration is a library that parses systemd-style durations.

It can parse durations into the following formats:

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:

Usage

See the examples directory for code examples.

Dependencies

~1–2MB
~40K SLoC