klyn.time.Duration.toString
method
public toString(format as String) as String
Description

Returns a string representation using a custom duration format.

Parameters
ParameterDescription
formatFormat using %h, %m and %s placeholders. %% emits a literal percent sign; unknown placeholders remain unchanged. A negative duration places one - before the first numeric placeholder, after any literal prefix. Components themselves remain non-negative. Durations truncated to zero have no sign.
Returns

A formatted string representation of this duration.

Throws
  • ValueException if the duration is NaN or infinite.
Example
import klyn.time
duration = Duration(0, 0, 0, 3661)
print(duration.toString("%h:%m:%s"))  # 1:1:1
assert Duration(seconds=-5).toString("Time: %s s") == "Time: -5 s"