diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt index 52a58c4a6..aa4126de1 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt @@ -53,16 +53,16 @@ object StringUtils { val formatSeconds = durationFormat.format(sec) if (days > 0) { - return "${days}d $formatHours:$formatMinutes:$formatSeconds ago" + return "${days}d $formatHours:$formatMinutes:$formatSeconds" } if (hours > 0) { - return "$formatHours:$formatMinutes:$formatSeconds ago" + return "$formatHours:$formatMinutes:$formatSeconds".removeAtBeginning("0") } if (minutes > 0) { - return "$formatMinutes:$formatSeconds ago" + return "$formatMinutes:$formatSeconds".removeAtBeginning("0") } if (sec > 0) { - return "${sec}s ago" + return "${sec}s" } return "Now" @@ -88,4 +88,6 @@ object StringUtils { return toString().replace("-", "") } -}
\ No newline at end of file +} + +private fun String.removeAtBeginning(text: String): String = if (this.startsWith(text)) substring(text.length) else this |