fmt_duration

Function fmt_duration 

Source
pub fn fmt_duration(duration: Duration) -> String
Expand description

Formats a Duration into a user-friendly format using days, hours, minutes, and seconds, and returns the formatted string.

Durations less than one minute include fractional seconds with nanosecond precision (up to 9 decimal places), while durations of one minute or longer display as whole seconds, rounded to the nearest second.

The output format includes the following components:

  • {days}d for days
  • {hours}h for hours
  • {minutes}m for minutes
  • {seconds}s for seconds

When all components are non-zero, the format appears as:

{days}d {hours}h {minutes}m {seconds}s