show track times without padded minutes

Minutes read as the plain value ("4:11", "0:05") and only hours keep the
formatted MM:SS tail, so nothing is zero-padded except the seconds.
This commit is contained in:
austinried
2026-10-04 00:30:02 +00:00
parent 51ed8fdd6b
commit 0d39a9de72
2 changed files with 10 additions and 4 deletions
@@ -317,7 +317,7 @@ internal fun formatTrackTime(seconds: Long): String {
return if (hours > 0) {
"%d:%02d:%02d".format(hours, minutes, secs)
} else {
"%02d:%02d".format(minutes, secs)
"%d:%02d".format(minutes, secs)
}
}
@@ -5,8 +5,14 @@ import org.junit.Test
class TrackTimeTest {
@Test
fun minutesAndSecondsAreZeroPadded() {
assertEquals("04:11", formatTrackTime(251))
fun minutesAreNotPaddedButSecondsAre() {
assertEquals("4:11", formatTrackTime(251))
assertEquals("12:05", formatTrackTime(725))
}
@Test
fun underAMinuteKeepsASingleLeadingZero() {
assertEquals("0:05", formatTrackTime(5))
}
@Test
@@ -16,6 +22,6 @@ class TrackTimeTest {
@Test
fun negativeDurationsClampToZero() {
assertEquals("00:00", formatTrackTime(-5))
assertEquals("0:00", formatTrackTime(-5))
}
}