Auto commit Tue Mar 24 06:01:01 PM CDT 2026

This commit is contained in:
Tretzi
2026-03-24 18:01:01 -05:00
parent 2a548edc9a
commit 1d4a599dd6
4 changed files with 158 additions and 25 deletions

View File

@@ -1,13 +1,18 @@
package com.mindmachine.mvp.session
import java.util.Locale
fun formatDuration(totalSec: Int): String {
val sec = totalSec.coerceAtLeast(0)
val h = sec / 3600
val m = (sec % 3600) / 60
val s = sec % 60
return when {
h > 0 -> String.format("%dh %02dm", h, m)
m > 0 -> String.format("%dm %02ds", m, s)
else -> String.format("%ds", s)
val totalMinutes = sec / 60f
return if (totalMinutes <= 60f) {
"${totalMinutes.toInt()} min"
} else {
val hours = totalMinutes / 60f
"${formatMaxTwoDecimals(hours)} h"
}
}
private fun formatMaxTwoDecimals(value: Float): String =
String.format(Locale.US, "%.2f", value).trimEnd('0').trimEnd('.')