From cc25593dd55a5c27cb044c1d1579c30fa4912b5d Mon Sep 17 00:00:00 2001 From: Luna712 <142361265+Luna712@users.noreply.github.com> Date: Thu, 16 Jul 2026 14:05:03 -0700 Subject: [PATCH] AccountManager: use Duration for secondsToReadable --- .../syncproviders/AccountManager.kt | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/syncproviders/AccountManager.kt b/app/src/main/java/com/lagradost/cloudstream3/syncproviders/AccountManager.kt index 68fba977714..a070ad41120 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/syncproviders/AccountManager.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/syncproviders/AccountManager.kt @@ -14,7 +14,7 @@ import com.lagradost.cloudstream3.syncproviders.providers.SubDlApi import com.lagradost.cloudstream3.syncproviders.providers.SubSourceApi import com.lagradost.cloudstream3.utils.DataStoreHelper import com.lagradost.cloudstream3.utils.videoskip.AnimeSkipAuth -import java.util.concurrent.TimeUnit +import kotlin.time.Duration.Companion.seconds abstract class AccountManager { companion object { @@ -145,23 +145,14 @@ abstract class AccountManager { const val APP_STRING_SHARE = "csshare" fun secondsToReadable(seconds: Int, completedValue: String): String { - var secondsLong = seconds.toLong() - val days = TimeUnit.SECONDS - .toDays(secondsLong) - secondsLong -= TimeUnit.DAYS.toSeconds(days) - - val hours = TimeUnit.SECONDS - .toHours(secondsLong) - secondsLong -= TimeUnit.HOURS.toSeconds(hours) - - val minutes = TimeUnit.SECONDS - .toMinutes(secondsLong) - secondsLong -= TimeUnit.MINUTES.toSeconds(minutes) - if (minutes < 0) { - return completedValue - } - //println("$days $hours $minutes") - return "${if (days != 0L) "$days" + "d " else ""}${if (hours != 0L) "$hours" + "h " else ""}${minutes}m" + if (seconds < 0) return completedValue + + val duration = seconds.seconds + val days = duration.inWholeDays + val hours = duration.inWholeHours % 24 + val minutes = duration.inWholeMinutes % 60 + + return "${if (days != 0L) "${days}d " else ""}${if (hours != 0L) "${hours}h " else ""}${minutes}m" } } -} \ No newline at end of file +}