extra constructor HMS that takes total seconds
This commit is contained in:
parent
360097cfc5
commit
dafa8cc606
2 changed files with 7 additions and 5 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue