jvmMain.com.bselzer.ktx.datetime.format.Duration.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of datetime-jvm Show documentation
Show all versions of datetime-jvm Show documentation
kotlinx.datetime extensions
The newest version!
package com.bselzer.ktx.datetime.format
import kotlin.time.Duration
/**
* Formats the duration into a user friendly representation with minutes as the highest unit.
*
* @see formatting
*/
actual fun Duration.minuteFormat(): String {
val totalSeconds = inWholeSeconds
val seconds: Int = (totalSeconds % 60).toInt()
val minutes: Int = (totalSeconds / 60).toInt()
return "%01d:%02d".format(minutes, seconds)
}