HMS now takes ints and has totalseconds and tostring functions

This commit is contained in:
lbarraga 2023-05-01 12:53:35 +02:00
parent 5b0cff2376
commit 1d6de333e4
2 changed files with 14 additions and 7 deletions

View file

@ -1,4 +1,15 @@
package be.ugent.sel.studeez.data.local.models.timer_functional
data class HoursMinutesSeconds(val hours: String, val minutes: String, val seconds: String
)
data class HoursMinutesSeconds(val hours: Int, val minutes: Int, val seconds: Int) {
fun getTotalSeconds(): Int {
return hours * 60 * 60 + minutes * 60 + seconds
}
override fun toString(): String {
val hoursString = hours.toString().padStart(2, '0')
val minutesString = minutes.toString().padStart(2, '0')
val secondsString = seconds.toString().padStart(2, '0')
return "$hoursString : $minutesString : $secondsString"
}
}

View file

@ -17,11 +17,7 @@ class Time(initialTime: Int) {
val minutes: Int = (time / (60)) % 60
val seconds: Int = time % 60
return HoursMinutesSeconds(
hours.toString().padStart(2, '0'),
minutes.toString().padStart(2, '0'),
seconds.toString().padStart(2, '0')
)
return HoursMinutesSeconds(hours, minutes, seconds)
}
}