blob: bfb734d7197e4837d4c9ec3b75c76055ec8fe3d0 (
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
41
42
43
44
45
46
47
|
module Model.Timer
( Timer
, initialTimer
, substractTimerTime
, initTime
) 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 =
let initialTime = 5 * 60 * 1000
in { creationTime = creationTime
, name = name
, initialTime = initialTime
, currentTime = initTime initialTime
, 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
initTime : Time -> Time
initTime t = t + 999
|