Duration: test toString in particular units

This commit is contained in:
Ilya Gorbunov
2019-04-06 03:46:30 +03:00
parent b9c56af9ba
commit c1f7fd0281
2 changed files with 38 additions and 0 deletions
@@ -146,7 +146,9 @@ public inline class Duration internal constructor(internal val _value: Double) :
}
fun toString(unit: DurationUnit, decimals: Int = 0): String {
require(decimals >= 0) { "decimals must be not negative, but was $decimals" }
// if (decimals == 0) return toString(unit)
if (isInfinite()) return _value.toString()
return formatToDecimals(inUnits(unit), decimals, unit.shortName())
}