aboutsummaryrefslogtreecommitdiff
path: root/src/Update/UpdateTimer.elm
blob: b3be08874cfc6e13ba6be1f7959a732a6cb66fac (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
module Update.UpdateTimer
  ( TimerAction(..)
  , updateTimer
  ) where

import Model.Timer (..)
import Model.Id (..)

type TimerAction =
  ToggleRunning
  | Restart
  | Stop

updateTimer : TimerAction -> Timer -> Timer
updateTimer action timer =
  case action of
    ToggleRunning ->
      { timer | isRunning <- not timer.isRunning }
    Restart ->
      { timer
      | isRunning <- True
      , currentTime <- initTime timer.initialTime
      }
    Stop ->
      { timer
      | isRunning <- False
      , currentTime <- initTime timer.initialTime
      }