blob: ddbe97ba0285fa1b9e5c4a9ae7279dbb4f9c6a40 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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
|