Skip to main content

Module duration

Module duration 

Source
Expand description

A signed duration type for the expression language.

The standard core::time::Duration is unsigned, but BEL’s duration arithmetic (subtraction, negation) needs signed values. This type stores a signed count of nanoseconds in an i128, which is far larger than any duration the language needs.

Structs§

Duration
A signed duration with nanosecond precision.

Functions§

format_duration
Formats a Duration into a string. The returned string represents the duration in the form “72h3m0.5s”. Leading zero units are omitted. As a special case, durations less than one second format use a smaller unit (milli-, micro-, or nanoseconds) to ensure that the leading digit is non-zero. The zero duration formats as 0s.
parse_duration
Parses a duration string into a Duration. Duration strings support the following grammar: