#duration-parser #duration #systemd #duration-string #time

systemd-duration

Convert systemd style time durations into other formats

4 releases

0.2.0 Mar 31, 2024
0.1.2 Mar 31, 2024
0.1.1 Mar 31, 2024
0.1.0 Mar 31, 2024

#1675 in Parser implementations

36 downloads per month

CC0 license

66KB
1.5K SLoC

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.


lib.rs:

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(86403));

Dependencies

~1–2.2MB
~43K SLoC