humanReadable

fun Duration.humanReadable(maxParts: Int = 2): String

Formats this duration as its most significant components, such as "1h 23m".

Components range from days down to milliseconds. Zero components are skipped, at most maxParts components are emitted, and a duration without any nonzero component, Duration.ZERO included, formats as "0s". Negative durations get a leading minus sign and infinite durations format as "Infinity".

Parameters

maxParts

the maximum number of components to include, at least 1.

Throws