module Model.Timer ( Timer , initialTimer , substractTimerTime ) where import List import Time (Time) type alias Timer = { creationTime : Time , name : String , initialTime : Time , currentTime : Time , isRunning : Bool } initialTimer : Time -> String -> Timer initialTimer creationTime name = { creationTime = creationTime , name = name , initialTime = 5 * 60 * 1000 , currentTime = 5 * 60 * 1000 , isRunning = True } substractTimerTime : Time -> Timer -> Timer substractTimerTime time timer = if timer.isRunning then if timer.currentTime - time <= 0.0 then { timer | currentTime <- 0.0 , isRunning <- False } else { timer | currentTime <- timer.currentTime - time } else timer