Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
timeutils
Copyright (C) 2019 Jonathan Lamothe jlamothe1980@gmail.com
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
Synopsis
- data Timer = Timer {}
- data TimeParts = TimeParts {}
- data Countdown = Countdown {}
- data Stopwatch = Stopwatch {}
- timerOffsetL :: Lens' Timer NominalDiffTime
- timerStartTimeL :: Lens' Timer (Maybe UTCTime)
- tpDaysL :: Lens' TimeParts Int
- tpHoursL :: Lens' TimeParts Int
- tpMinutesL :: Lens' TimeParts Int
- tpSecondsL :: Lens' TimeParts Int
- tpMillisL :: Lens' TimeParts Int
- countdownLengthL :: Lens' Countdown NominalDiffTime
- countdownTimerL :: Lens' Countdown Timer
- stopwatchTimerL :: Lens' Stopwatch Timer
- stopwatchLapsL :: Lens' Stopwatch [NominalDiffTime]
- newTimer :: Timer
- newTimeParts :: TimeParts
- newCountdown :: NominalDiffTime -> Countdown
- newStopwatch :: Stopwatch
- startTimer :: Timer -> IO Timer
- stopTimer :: Timer -> IO Timer
- timeElapsed :: Timer -> IO NominalDiffTime
- startCountdown :: Countdown -> IO Countdown
- stopCountdown :: Countdown -> IO Countdown
- timeRemaining :: Countdown -> IO NominalDiffTime
- countdownIsCompleted :: Countdown -> IO Bool
- startStopwatch :: Stopwatch -> IO Stopwatch
- stopStopwatch :: Stopwatch -> IO Stopwatch
- newLap :: Stopwatch -> IO Stopwatch
- currentLap :: Stopwatch -> IO NominalDiffTime
- allLaps :: Stopwatch -> IO [NominalDiffTime]
- totalStopwatchTime :: Stopwatch -> IO NominalDiffTime
- decomposeNDT :: NominalDiffTime -> TimeParts
- composeNDT :: TimeParts -> NominalDiffTime
- humanNDT :: NominalDiffTime -> String
- timerIsRunning :: Timer -> Bool
- timerIsStarted :: Timer -> Bool
- startTimerAt :: UTCTime -> Timer -> Timer
- stopTimerAt :: UTCTime -> Timer -> Timer
- timeElapsedAt :: UTCTime -> Timer -> NominalDiffTime
- countdownIsRunning :: Countdown -> Bool
- countdownIsStarted :: Countdown -> Bool
- startCountdownAt :: UTCTime -> Countdown -> Countdown
- stopCountdownAt :: UTCTime -> Countdown -> Countdown
- timeRemainingAt :: UTCTime -> Countdown -> NominalDiffTime
- countdownIsCompletedAt :: UTCTime -> Countdown -> Bool
- stopwatchIsRunning :: Stopwatch -> Bool
- stopwatchIsStarted :: Stopwatch -> Bool
- startStopwatchAt :: UTCTime -> Stopwatch -> Stopwatch
- stopStopwatchAt :: UTCTime -> Stopwatch -> Stopwatch
- newLapAt :: UTCTime -> Stopwatch -> Stopwatch
- currentLapAt :: UTCTime -> Stopwatch -> NominalDiffTime
- allLapsAt :: UTCTime -> Stopwatch -> [NominalDiffTime]
- totalStopwatchTimeAt :: UTCTime -> Stopwatch -> NominalDiffTime
Types
A type that keeps track of the passage of time
Timer | |
|
Represents a NominalDiffTime
broken down into days, hours,
minutes, seconds and milliseconds
Represents a timed countdown
Countdown | |
|
Tracks the time of multiple laps
Stopwatch | |
|
Lenses
Timer Lenses
timerOffsetL :: Lens' Timer NominalDiffTime Source #
Lens for the timerOffset
attribute
timerStartTimeL :: Lens' Timer (Maybe UTCTime) Source #
Lens for the timerStartTime
attribute
TimeParts Lenses
Countdown Lenses
countdownLengthL :: Lens' Countdown NominalDiffTime Source #
Lens for the countdownLength
attribute
countdownTimerL :: Lens' Countdown Timer Source #
Lens for the countdownTimer
attribute
Stopwatch Lenses
stopwatchTimerL :: Lens' Stopwatch Timer Source #
Lens for the stopwatchTimer
attribute
stopwatchLapsL :: Lens' Stopwatch [NominalDiffTime] Source #
Lens for the stopwatchLaps
attribute
Constructors
newTimeParts :: TimeParts Source #
New instance of a TimeParts
value
newStopwatch :: Stopwatch Source #
New instance of a stopwatch
Impure Functions
Timer Functions
:: Timer | The |
-> IO NominalDiffTime | The amount of time elapsed |
Calculates the amount of time elapsed on a Timer
Countdown Functions
Starts a Countdown
Stops a Countdown
:: Countdown | The |
-> IO NominalDiffTime | The amount of time remaining |
Calculates the amount of time remaining in a Countdown
:: Countdown | The |
-> IO Bool | Returns |
Determines whether or not a Countdown
has completed.
Stopwatch Functions
Starts a Stopwatch
Stops a Stopwatch
Starts a new lap
:: Stopwatch | The |
-> IO NominalDiffTime | Returns the amount of time elapsed in the current lap |
Returns the time of the current lap from a Stopwatch
:: Stopwatch | The |
-> IO [NominalDiffTime] | Returns the lap times (most recent first) |
Returns the lap times for a Stopwatch
:: Stopwatch | The |
-> IO NominalDiffTime | Returns the total run time |
Calculates the total run time of a Stopwatch
Pure Functions
decomposeNDT :: NominalDiffTime -> TimeParts Source #
Converts a NominalDiffTime
to a TimeParts
value
composeNDT :: TimeParts -> NominalDiffTime Source #
Converts a TimeParts
value to a NominalDiffTime
humanNDT :: NominalDiffTime -> String Source #
Converts a NominalDiffTime
into a more human-readable format
Timer Functions
Determines whether or not a Timer
is running
Determines whether or not a Timer
has been started (even if it
is currently stopped)
Starts a Timer
from a given time
Stops a Timer
from a given time
:: UTCTime | The current time |
-> Timer | The |
-> NominalDiffTime | The amount of time elapsed |
Calculates the amount of time elapsed on a Timer
from a given
time
Countdown Functions
Determines whether or not a Countdown
is running
Determines whether or not a Countdown
has been started (even if
subsequently stopped)
Starts a Countdown
using a given time
Stops a Countdown
using a given time
:: UTCTime | The current time |
-> Countdown | The |
-> NominalDiffTime | The amount of time remaining |
Calculates the amount of time remaining in a Countdown
at a
given time
countdownIsCompletedAt Source #
:: UTCTime | The current time |
-> Countdown | The |
-> Bool | Returns |
Determines if a Countdown
is completed at a given time
Stopwatch Functions
Determines whether or not a Stopwatch
is running
Determines whether or not a stopwatch has been started (even if subsequently stopped)
Starts a Stopwatch
at a given time
Stops a Stopwatch
at a given time
:: UTCTime | The currebt time |
-> Stopwatch | The |
-> Stopwatch | The modified |
Starts a new lap at a given time
:: UTCTime | The current time |
-> Stopwatch | The |
-> NominalDiffTime | The elapsed time for the current lap |
Determines the length of the current lap given a time
:: UTCTime | The current time |
-> Stopwatch | The |
-> [NominalDiffTime] | The lap times (most recent first) |
Returns the lap times from a Stopwatch
given a time
:: UTCTime | The current time |
-> Stopwatch | The |
-> NominalDiffTime | The total run time |
Calculates the total runtime of a Stopwatch
given a time