extra constructor HMS that takes total seconds

This commit is contained in:
lbarraga 2023-05-01 17:51:51 +02:00
parent 360097cfc5
commit dafa8cc606
2 changed files with 7 additions and 5 deletions

View file

@ -2,6 +2,12 @@ package be.ugent.sel.studeez.data.local.models.timer_functional
data class HoursMinutesSeconds(val hours: Int, val minutes: Int, val seconds: Int) {
constructor(sec: Int): this(
sec / (60 * 60),
(sec / (60)) % 60,
sec % 60
)
fun getTotalSeconds(): Int {
return hours * 60 * 60 + minutes * 60 + seconds
}

View file

@ -13,11 +13,7 @@ class Time(initialTime: Int) {
}
fun getAsHMS(): HoursMinutesSeconds {
val hours: Int = time / (60 * 60)
val minutes: Int = (time / (60)) % 60
val seconds: Int = time % 60
return HoursMinutesSeconds(hours, minutes, seconds)
return HoursMinutesSeconds(time)
}
}