time-machine-0.1.0: A library to mock the current time.

Safe HaskellNone
LanguageHaskell2010

Control.Monad.TimeMachine.Engine

Contents

Synopsis

MonadTime Class

getTimeZone :: MonadTime m => UTCTime -> m TimeZone Source #

Returns the mocked time zone at the given point of time.

getCurrentTimeZone :: MonadTime m => m TimeZone Source #

Returns the mocked time zone at the mocked current time.

utcToLocalZonedTime :: MonadTime m => UTCTime -> m ZonedTime Source #

Returns the mocked local time at the given point of time.

getZonedTime :: MonadTime m => m ZonedTime Source #

Returns the mocked local time at the mocked current time.

Functions

departFor :: (MonadIO m, MonadTime m) => Destination -> TimeZoneName -> Acceleration -> TimeMachineT m a -> m a Source #

Switches the MonadTime contexts. You can specify all of the point of time, the time zone and the setting of speed for mocking at once.

travelTo :: (MonadIO m, MonadTime m) => Destination -> TimeMachineT m a -> m a Source #

Switches the mocked current time in the context.

backTo :: (MonadIO m, MonadTime m) => Destination -> TimeMachineT m a -> m a Source #

An alias of travelTo.

jumpTo :: (MonadIO m, MonadTime m) => TimeZoneName -> TimeMachineT m a -> m a Source #

Switches the mocked current time zone in the context.

accelerate :: (MonadIO m, MonadTime m) => Acceleration -> TimeMachineT m a -> m a Source #

Changes the mocked speed of time in the context.

halt :: (MonadIO m, MonadTime m) => TimeMachineT m a -> m a Source #

Stops the time to advence in the context.

Configurations

newtype TimeScale Source #

A data type to represents the speed of time. It corresponds how many seconds are in the real second, i.e. TimeScale 1 is equivalent to the real speed of time.

Constructors

TimeScale 

data Destination Source #

A data type to represent a point of time for mocking.

Constructors

None

Nothing to mock.

Absolute UTCTime

An absolute point in UTC.

Zoned LocalTime

A local time in the mocked current time zone.

Relative TimeInterval

An interval from the mocked current time.

type TimeZoneName = String Source #

Names of time zones, e.g. "Asia/Tokyo" or "Europe/Paris".

data Acceleration Source #

A data type to represent how to change the mocked speed of time.

Constructors

Keep

Nothing to change.

Velocity TimeScale

Sets the speed to the given scale.

Factor TimeScale

Sets the speed acccording to the current speed.

Monad Transformer

data TimeMachineT m a Source #

A monad transformer to stack the MonadTime contexts.