From 8dd235557062826138de17e51da24f3c9c58780e Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sun, 16 Jun 2024 19:17:08 +0200 Subject: code cleanup --- src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt index 3af450db4..e1431350e 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt @@ -36,13 +36,12 @@ object TimeUtils { for ((unit, value) in parts) { if (value != 0 || (unit == TimeUnit.SECOND && showMilliSeconds)) { val formatted = value.addSeparators() - val formattedMillis = (millis / 100).toInt() - val name = unit.getName(value, longName) - val text = if (unit == TimeUnit.SECOND && showMilliSeconds) { + val formattedMillis = (millis / 100).toInt() "$formatted.$formattedMillis" } else formatted + val name = unit.getName(value, longName) append("$text$name ") if (maxUnits != -1 && ++currentUnits == maxUnits) break } @@ -58,8 +57,7 @@ object TimeUtils { else -> default } - val Duration.inWholeTicks: Int - get() = (inWholeMilliseconds / 50).toInt() + val Duration.inWholeTicks: Int get() = (inWholeMilliseconds / 50).toInt() fun getDuration(string: String) = getMillis(string.replace("m", "m ").replace(" ", " ").trim()) @@ -96,13 +94,9 @@ object TimeUtils { seconds + minutes } - 1 -> { - split[0].toInt() * 1000 - } + 1 -> split[0].toInt() * 1000 - else -> { - throw RuntimeException("Invalid format: '$string'") - } + else -> throw RuntimeException("Invalid format: '$string'") }.milliseconds } -- cgit