diff options
Diffstat (limited to 'src/Update/UpdateTimer.elm')
-rw-r--r-- | src/Update/UpdateTimer.elm | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/Update/UpdateTimer.elm b/src/Update/UpdateTimer.elm index 3eba549..e4671d9 100644 --- a/src/Update/UpdateTimer.elm +++ b/src/Update/UpdateTimer.elm @@ -3,26 +3,40 @@ module Update.UpdateTimer , updateTimer ) where +import Time (Time) + import Model.Timer (..) import Model.Id (..) type TimerAction = Restart + | Pause | ToggleRunning | Stop + | SetTime Time updateTimer : TimerAction -> Timer -> Timer updateTimer action timer = case action of - ToggleRunning -> - { timer | isRunning <- timer.currentTime > 0.0 && not timer.isRunning } Restart -> { timer | isRunning <- True , currentTime <- initTime timer.initialTime } + Pause -> + { timer + | isRunning <- False + } + ToggleRunning -> + { timer | isRunning <- timer.currentTime > 0.0 && not timer.isRunning } Stop -> { timer | isRunning <- False , currentTime <- initTime timer.initialTime } + SetTime time -> + let augmentedTime = time + 999 + in { timer + | initialTime <- augmentedTime + , currentTime <- augmentedTime + } |