Format Duration
Package: kwave.utilities
Format calendarDuration object into string containing hours, minutes, and seconds.
Syntax
formattedDuration = formatDuration(elapsedTime);
Description
The formatDuration function takes a duration or calendarDuration object as input and outputs a formatted string representing the duration. The output string is composed of hours (if non-zero), minutes (if non-zero), and seconds, each followed by the respective unit label (h, m, s). This function is particularly useful for displaying human-readable durations in contexts such as performance measurement and event timing.
Examples
elapsedTime = hours(1) + minutes(23) + seconds(45);
formattedDuration = kwave.utilities.formatDuration(elapsedTime);
disp(formattedDuration);
1h 23m 45s
Input Arguments
elapsedTime- (duration) The duration to be formatted.
Output Arguments
formattedDuration- (string) A formatted string representing the duration. The string includes hours (if non-zero), minutes (if non-zero), and seconds, each followed by the respective unit label (h, m, s).