Skip to content

Commit

Permalink
Fix comments and make formatter private
Browse files Browse the repository at this point in the history
  • Loading branch information
MGaetan89 committed Jan 23, 2024
1 parent ef8c4fa commit 0815d87
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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, _ ->
Expand All @@ -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)
}
}
Expand Down

0 comments on commit 0815d87

Please sign in to comment.