#duration #systemd #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

#751 in Parser implementations

Download history 122/week @ 2024-03-26 96/week @ 2024-04-02 6/week @ 2024-04-09

224 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–2.3MB
~45K SLoC