public toString(format as String) as String
Returns a string representation using a custom duration format.
| Parameter | Description |
|---|---|
format | Format 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. |
A formatted string representation of this duration.
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"