Skip to content

Commit e61271a

Browse files
committed
translate helper
1 parent 409a9d9 commit e61271a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/commonMain/kotlin/spp.protocol/utils/TimeUtils.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,22 @@ fun Double.fromPerSecondToPrettyFrequency(translate: (String)->String = { it }):
4949
}
5050
}
5151

52-
fun Long.toPrettyDuration(): String {
52+
fun Long.toPrettyDuration(translate: (String)->String = { it }): String {
5353
val days = this / 86400000.0
5454
if (days > 1) {
55-
return "${days.toInt()}d"
55+
return "${days.toInt()}" + translate("dys")
5656
}
5757
val hours = this / 3600000.0
5858
if (hours > 1) {
59-
return "${hours.toInt()}h"
59+
return "${hours.toInt()}" + translate("hrs")
6060
}
6161
val minutes = this / 60000.0
6262
if (minutes > 1) {
63-
return "${minutes.toInt()}m"
63+
return "${minutes.toInt()}" + translate("mins")
6464
}
6565
val seconds = this / 1000.0
6666
if (seconds > 1) {
67-
return "${seconds.toInt()}s"
67+
return "${seconds.toInt()}" + translate("secs")
6868
}
69-
return "${this}ms"
69+
return "$this" + translate("ms")
7070
}

0 commit comments

Comments
 (0)