diff --git a/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/ui/DurationFormatter.kt b/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/ui/DurationFormatter.kt index f5c2785de..8044de764 100644 --- a/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/ui/DurationFormatter.kt +++ b/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/ui/DurationFormatter.kt @@ -7,7 +7,7 @@ package ch.srgssr.pillarbox.demo.shared.ui import kotlin.time.Duration /** - * @return a formatter function for displaying the duration based on its length. + * @return a formatter function to display the duration based on its length. */ fun Duration.getFormatter(): (Duration) -> String { return if (inWholeHours <= 0) DurationFormatter::formatMinutesSeconds else DurationFormatter::formatHourMinutesSeconds @@ -16,13 +16,13 @@ fun Duration.getFormatter(): (Duration) -> String { /** * Duration formatter */ -object DurationFormatter { +private object DurationFormatter { private const val FORMAT_HOURS_MINUTES_SECONDS = "%02d:%02d:%02d" private const val FORMAT_MINUTES_SECONDS = "%02d:%02d" /** * @param duration The duration to format. - * @return Format hour minutes seconds + * @return The duration formatted as "hh:mm:ss" */ fun formatHourMinutesSeconds(duration: Duration): String { return duration.toComponents { hours, minutes, seconds, _ -> @@ -32,10 +32,10 @@ object DurationFormatter { /** * @param duration The duration to format. - * @return Format minutes seconds + * @return The duration formatted as "mm:ss" */ fun formatMinutesSeconds(duration: Duration): String { - return duration.toComponents { _, minutes, seconds, _ -> + return duration.toComponents { minutes, seconds, _ -> FORMAT_MINUTES_SECONDS.format(minutes, seconds) } }