diff options
author | Joris Guyonvarch | 2015-03-16 00:15:05 +0100 |
---|---|---|
committer | Joris Guyonvarch | 2015-03-16 00:15:05 +0100 |
commit | cd3b37adebca99138fad1acca37908183036ace9 (patch) | |
tree | d566ae0564d82ab94901e4deda98f36abd22ad2d /src/Model/Timer.elm |
Initial commit, can create and name 5 minute timers, can toggle running state
Diffstat (limited to 'src/Model/Timer.elm')
-rw-r--r-- | src/Model/Timer.elm | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/Model/Timer.elm b/src/Model/Timer.elm new file mode 100644 index 0000000..ddbe97b --- /dev/null +++ b/src/Model/Timer.elm @@ -0,0 +1,40 @@ +module Model.Timer + ( Timer + , initialTimer + , substractTimerTime + ) where + +import List +import Time (Time) + +type alias Timer = + { creationTime : Time + , name : String + , time : Time + , isRunning : Bool + } + +initialTimer : Time -> String -> Timer +initialTimer creationTime name = + { creationTime = creationTime + , name = name + , time = 5 * 60 * 1000 + , isRunning = True + } + +substractTimerTime : Time -> Timer -> Timer +substractTimerTime time timer = + if timer.isRunning + then + if timer.time - time <= 0.0 + then + { timer + | time <- 0.0 + , isRunning <- False + } + else + { timer + | time <- timer.time - time + } + else + timer |