timeutils-0.1.0: Time utilities

Safe HaskellSafe
LanguageHaskell2010

Data.Time.Utils

Contents

Description

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

Types

data Timer Source #

A type that keeps track of the passage of time

Constructors

Timer 

Fields

Instances
Eq Timer Source # 
Instance details

Defined in Data.Time.Utils

Methods

(==) :: Timer -> Timer -> Bool #

(/=) :: Timer -> Timer -> Bool #

Show Timer Source # 
Instance details

Defined in Data.Time.Utils

Methods

showsPrec :: Int -> Timer -> ShowS #

show :: Timer -> String #

showList :: [Timer] -> ShowS #

data TimeParts Source #

Represents a NominalDiffTime broken down into days, hours, minutes, seconds and milliseconds

Constructors

TimeParts 

Fields

Instances
Eq TimeParts Source # 
Instance details

Defined in Data.Time.Utils

Show TimeParts Source # 
Instance details

Defined in Data.Time.Utils

data Countdown Source #

Represents a timed countdown

Constructors

Countdown 

Fields

Instances
Eq Countdown Source # 
Instance details

Defined in Data.Time.Utils

Show Countdown Source # 
Instance details

Defined in Data.Time.Utils

data Stopwatch Source #

Tracks the time of multiple laps

Constructors

Stopwatch 

Fields

Instances
Eq Stopwatch Source # 
Instance details

Defined in Data.Time.Utils

Show Stopwatch Source # 
Instance details

Defined in Data.Time.Utils

Lenses

Timer Lenses

TimeParts Lenses

tpDaysL :: Lens' TimeParts Int Source #

Lens for the tpDays attribute

tpHoursL :: Lens' TimeParts Int Source #

Lens for the tpHours attribute

tpMinutesL :: Lens' TimeParts Int Source #

Lens for the tpMinutes attribute

tpSecondsL :: Lens' TimeParts Int Source #

Lens for the tpSeconds attribute

tpMillisL :: Lens' TimeParts Int Source #

Lens for the tpMillis attribute

Countdown Lenses

Stopwatch Lenses

Constructors

newTimer :: Timer Source #

New instance of a Timer

newTimeParts :: TimeParts Source #

New instance of a TimeParts value

newCountdown Source #

Arguments

:: NominalDiffTime

The time length

-> Countdown 

New instance of a Countdown

newStopwatch :: Stopwatch Source #

New instance of a stopwatch

Impure Functions

Timer Functions

startTimer Source #

Arguments

:: Timer

The Timer being started

-> IO Timer

The modified Timer

Starts a Timer

stopTimer Source #

Arguments

:: Timer

The Timer being stopped

-> IO Timer

The modified Timer

Stops a Timer

timeElapsed Source #

Arguments

:: Timer

The Timer being checked

-> IO NominalDiffTime

The amount of time elapsed

Calculates the amount of time elapsed on a Timer

Countdown Functions

startCountdown Source #

Arguments

:: Countdown

The Countdown being started

-> IO Countdown

Returns the modified Countdown

Starts a Countdown

stopCountdown Source #

Arguments

:: Countdown

The Countdown being stopped

-> IO Countdown

Returns the modified Countdown

Stops a Countdown

timeRemaining Source #

Arguments

:: Countdown

The Countdown being checked

-> IO NominalDiffTime

The amount of time remaining

Calculates the amount of time remaining in a Countdown

countdownIsCompleted Source #

Arguments

:: Countdown

The Countdown being checked

-> IO Bool

Returns True if the Countdown has completed, False otherwise

Determines whether or not a Countdown has completed.

Stopwatch Functions

startStopwatch Source #

Arguments

:: Stopwatch

The Stopwatch being started

-> IO Stopwatch

Returns the modified Stopwatch

Starts a Stopwatch

stopStopwatch Source #

Arguments

:: Stopwatch

The Stopwatch being stopped

-> IO Stopwatch

Returns the modified Stopwatch

Stops a Stopwatch

newLap Source #

Arguments

:: Stopwatch

The Stopwatch being modified

-> IO Stopwatch

Returns the Stopwatch being modified

Starts a new lap

currentLap Source #

Arguments

:: Stopwatch

The Stopwatch being checked

-> IO NominalDiffTime

Returns the amount of time elapsed in the current lap

Returns the time of the current lap from a Stopwatch

allLaps Source #

Arguments

:: Stopwatch

The Stopwatch being checked

-> IO [NominalDiffTime]

Returns the lap times (most recent first)

Returns the lap times for a Stopwatch

totalStopwatchTime Source #

Arguments

:: Stopwatch

The Stopwatch being checked

-> IO NominalDiffTime

Returns the total run time

Calculates the total run time of a Stopwatch

Pure Functions

humanNDT :: NominalDiffTime -> String Source #

Converts a NominalDiffTime into a more human-readable format

Timer Functions

timerIsRunning Source #

Arguments

:: Timer

The Timer being checked

-> Bool 

Determines whether or not a Timer is running

timerIsStarted Source #

Arguments

:: Timer

The Timer being checked

-> Bool

True if the timer has been started, False otherwise

Determines whether or not a Timer has been started (even if it is currently stopped)

startTimerAt Source #

Arguments

:: UTCTime

The current time

-> Timer

The Timer being started

-> Timer

The modified Timer

Starts a Timer from a given time

stopTimerAt Source #

Arguments

:: UTCTime

The current time

-> Timer

The Timer being stopped

-> Timer

The modified Timer

Stops a Timer from a given time

timeElapsedAt Source #

Arguments

:: UTCTime

The current time

-> Timer

The Timer being checked

-> NominalDiffTime

The amount of time elapsed

Calculates the amount of time elapsed on a Timer from a given time

Countdown Functions

countdownIsRunning Source #

Arguments

:: Countdown

The Countdown being checked

-> Bool

True if running, False otherwise

Determines whether or not a Countdown is running

countdownIsStarted Source #

Arguments

:: Countdown

The Countdown being checked

-> Bool

True if it has been started, False otherwise

Determines whether or not a Countdown has been started (even if subsequently stopped)

startCountdownAt Source #

Arguments

:: UTCTime

The current time

-> Countdown

The Countdown being started

-> Countdown

The modified Countdown

Starts a Countdown using a given time

stopCountdownAt Source #

Arguments

:: UTCTime

The current time

-> Countdown

The Countdown being stopped

-> Countdown

The modified Countdown

Stops a Countdown using a given time

timeRemainingAt Source #

Arguments

:: UTCTime

The current time

-> Countdown

The Countdown being checked

-> NominalDiffTime

The amount of time remaining

Calculates the amount of time remaining in a Countdown at a given time

countdownIsCompletedAt Source #

Arguments

:: UTCTime

The current time

-> Countdown

The Countdown being checked

-> Bool

Returns True if the Countdown has completed, False otherwise.

Determines if a Countdown is completed at a given time

Stopwatch Functions

stopwatchIsRunning Source #

Arguments

:: Stopwatch

The Stopwatch being checked

-> Bool

True if the Stopwatch is running, False otherwise

Determines whether or not a Stopwatch is running

stopwatchIsStarted Source #

Arguments

:: Stopwatch

The Stopwatch being checked

-> Bool

True if started, False otherwise

Determines whether or not a stopwatch has been started (even if subsequently stopped)

startStopwatchAt Source #

Arguments

:: UTCTime

The current time

-> Stopwatch

The Stopwatch being started

-> Stopwatch

The modified Stopwatch

Starts a Stopwatch at a given time

stopStopwatchAt Source #

Arguments

:: UTCTime

The current time

-> Stopwatch

The Stopwatch being stopped

-> Stopwatch

The modified Stopwatch

Stops a Stopwatch at a given time

newLapAt Source #

Arguments

:: UTCTime

The currebt time

-> Stopwatch

The Stopwatch being modified

-> Stopwatch

The modified Stopwatch

Starts a new lap at a given time

currentLapAt Source #

Arguments

:: UTCTime

The current time

-> Stopwatch

The Stopwatch being checkwd

-> NominalDiffTime

The elapsed time for the current lap

Determines the length of the current lap given a time

allLapsAt Source #

Arguments

:: UTCTime

The current time

-> Stopwatch

The Stopwatch being checked

-> [NominalDiffTime]

The lap times (most recent first)

Returns the lap times from a Stopwatch given a time

totalStopwatchTimeAt Source #

Arguments

:: UTCTime

The current time

-> Stopwatch

The Stopwatch being checked

-> NominalDiffTime

The total run time

Calculates the total runtime of a Stopwatch given a time