Skip to main content

format_duration

Function format_duration 

Source
pub fn format_duration(d: &Duration) -> String
Expand description

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.

This is a direct port of the Go version of the time.Duration.String() function.