hourglass-0.2.12: simple performant time related library

License | BSD-style
Maintainer | Vincent Hanquez <vincent@snarc.org>
Stability | experimental
Portability | unknown
Safe Haskell | None
Language | Haskell2010

Data.Hourglass.Epoch

Contents

- computer time tracking with various epoch
- Epoch
  - standard and usual epochs

Description

Epoch tracking

Synopsis

- newtype ElapsedSince epoch = ElapsedSince Seconds
- data ElapsedSinceP epoch = ElapsedSinceP !(ElapsedSince epoch) !NanoSeconds
- class Epoch epoch where
  - epochName :: epoch -> String
  - epochDiffToUnix :: epoch -> Seconds
- data UnixEpoch = UnixEpoch
- data WindowsEpoch = WindowsEpoch

# computer time tracking with various epoch

newtype ElapsedSince epoch Source #

A number of seconds elapsed since an epoch.

Constructors

ElapsedSince Seconds |

Instances

Eq (ElapsedSince epoch) Source # |
Instance details Defined in Data.Hourglass.Epoch Methods (==) :: ElapsedSince epoch -> ElapsedSince epoch -> Bool Source # (/=) :: ElapsedSince epoch -> ElapsedSince epoch -> Bool Source #
Data epoch => Data (ElapsedSince epoch) Source # |

Instance details

Defined in Data.Hourglass.Epoch

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ElapsedSince epoch -> c (ElapsedSince epoch) Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (ElapsedSince epoch) Source #

toConstr :: ElapsedSince epoch -> Constr Source #

dataTypeOf :: ElapsedSince epoch -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (ElapsedSince epoch)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (ElapsedSince epoch)) Source #

gmapT :: (forall b. Data b => b -> b) -> ElapsedSince epoch -> ElapsedSince epoch Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ElapsedSince epoch -> r Source #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ElapsedSince epoch -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> ElapsedSince epoch -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> ElapsedSince epoch -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> ElapsedSince epoch -> m (ElapsedSince epoch) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ElapsedSince epoch -> m (ElapsedSince epoch) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ElapsedSince epoch -> m (ElapsedSince epoch) Source #

Num (ElapsedSince epoch) Source # |

Instance details

Defined in Data.Hourglass.Epoch

Methods

(+) :: ElapsedSince epoch -> ElapsedSince epoch -> ElapsedSince epoch Source #

(-) :: ElapsedSince epoch -> ElapsedSince epoch -> ElapsedSince epoch Source #

(*) :: ElapsedSince epoch -> ElapsedSince epoch -> ElapsedSince epoch Source #

negate :: ElapsedSince epoch -> ElapsedSince epoch Source #

abs :: ElapsedSince epoch -> ElapsedSince epoch Source #

signum :: ElapsedSince epoch -> ElapsedSince epoch Source #

fromInteger :: Integer -> ElapsedSince epoch Source #

Ord (ElapsedSince epoch) Source # |

Instance details

Defined in Data.Hourglass.Epoch

Methods

compare :: ElapsedSince epoch -> ElapsedSince epoch -> Ordering Source #

(<) :: ElapsedSince epoch -> ElapsedSince epoch -> Bool Source #

(<=) :: ElapsedSince epoch -> ElapsedSince epoch -> Bool Source #

(>) :: ElapsedSince epoch -> ElapsedSince epoch -> Bool Source #

(>=) :: ElapsedSince epoch -> ElapsedSince epoch -> Bool Source #

max :: ElapsedSince epoch -> ElapsedSince epoch -> ElapsedSince epoch Source #

min :: ElapsedSince epoch -> ElapsedSince epoch -> ElapsedSince epoch Source #

Read (ElapsedSince epoch) Source # |
Instance details Defined in Data.Hourglass.Epoch Methods readsPrec :: Int -> ReadS (ElapsedSince epoch) Source # readList :: ReadS [ElapsedSince epoch] Source # readPrec :: ReadPrec (ElapsedSince epoch) Source # readListPrec :: ReadPrec [ElapsedSince epoch] Source #
Show (ElapsedSince epoch) Source # |
Instance details Defined in Data.Hourglass.Epoch Methods showsPrec :: Int -> ElapsedSince epoch -> ShowS Source # show :: ElapsedSince epoch -> String Source # showList :: [ElapsedSince epoch] -> ShowS Source #
NFData (ElapsedSince epoch) Source # |
Instance details Defined in Data.Hourglass.Epoch Methods rnf :: ElapsedSince epoch -> () Source #
Epoch epoch => Time (ElapsedSince epoch) Source # |
Instance details Defined in Data.Hourglass.Epoch Methods timeFromElapsedP :: ElapsedP -> ElapsedSince epoch Source # timeFromElapsed :: Elapsed -> ElapsedSince epoch Source #
Epoch epoch => Timeable (ElapsedSince epoch) Source # |
Instance details Defined in Data.Hourglass.Epoch Methods timeGetElapsedP :: ElapsedSince epoch -> ElapsedP Source # timeGetElapsed :: ElapsedSince epoch -> Elapsed Source # timeGetNanoSeconds :: ElapsedSince epoch -> NanoSeconds Source #

data ElapsedSinceP epoch Source #

A number of seconds and nanoseconds elapsed since an epoch.

Constructors

ElapsedSinceP !(ElapsedSince epoch) !NanoSeconds |

Instances

Eq (ElapsedSinceP epoch) Source # |
Instance details Defined in Data.Hourglass.Epoch Methods (==) :: ElapsedSinceP epoch -> ElapsedSinceP epoch -> Bool Source # (/=) :: ElapsedSinceP epoch -> ElapsedSinceP epoch -> Bool Source #
Data epoch => Data (ElapsedSinceP epoch) Source # |

Instance details

Defined in Data.Hourglass.Epoch

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ElapsedSinceP epoch -> c (ElapsedSinceP epoch) Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (ElapsedSinceP epoch) Source #

toConstr :: ElapsedSinceP epoch -> Constr Source #

dataTypeOf :: ElapsedSinceP epoch -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (ElapsedSinceP epoch)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (ElapsedSinceP epoch)) Source #

gmapT :: (forall b. Data b => b -> b) -> ElapsedSinceP epoch -> ElapsedSinceP epoch Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ElapsedSinceP epoch -> r Source #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ElapsedSinceP epoch -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> ElapsedSinceP epoch -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> ElapsedSinceP epoch -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> ElapsedSinceP epoch -> m (ElapsedSinceP epoch) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ElapsedSinceP epoch -> m (ElapsedSinceP epoch) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ElapsedSinceP epoch -> m (ElapsedSinceP epoch) Source #

Num (ElapsedSinceP e) Source # |

Instance details

Defined in Data.Hourglass.Epoch

Methods

(+) :: ElapsedSinceP e -> ElapsedSinceP e -> ElapsedSinceP e Source #

(-) :: ElapsedSinceP e -> ElapsedSinceP e -> ElapsedSinceP e Source #

(*) :: ElapsedSinceP e -> ElapsedSinceP e -> ElapsedSinceP e Source #

negate :: ElapsedSinceP e -> ElapsedSinceP e Source #

abs :: ElapsedSinceP e -> ElapsedSinceP e Source #

signum :: ElapsedSinceP e -> ElapsedSinceP e Source #

fromInteger :: Integer -> ElapsedSinceP e Source #

Ord (ElapsedSinceP epoch) Source # |

Instance details

Defined in Data.Hourglass.Epoch

Methods

compare :: ElapsedSinceP epoch -> ElapsedSinceP epoch -> Ordering Source #

(<) :: ElapsedSinceP epoch -> ElapsedSinceP epoch -> Bool Source #

(<=) :: ElapsedSinceP epoch -> ElapsedSinceP epoch -> Bool Source #

(>) :: ElapsedSinceP epoch -> ElapsedSinceP epoch -> Bool Source #

(>=) :: ElapsedSinceP epoch -> ElapsedSinceP epoch -> Bool Source #

max :: ElapsedSinceP epoch -> ElapsedSinceP epoch -> ElapsedSinceP epoch Source #

min :: ElapsedSinceP epoch -> ElapsedSinceP epoch -> ElapsedSinceP epoch Source #

Read (ElapsedSinceP epoch) Source # |
Instance details Defined in Data.Hourglass.Epoch Methods readsPrec :: Int -> ReadS (ElapsedSinceP epoch) Source # readList :: ReadS [ElapsedSinceP epoch] Source # readPrec :: ReadPrec (ElapsedSinceP epoch) Source # readListPrec :: ReadPrec [ElapsedSinceP epoch] Source #
Show (ElapsedSinceP epoch) Source # |
Instance details Defined in Data.Hourglass.Epoch Methods showsPrec :: Int -> ElapsedSinceP epoch -> ShowS Source # show :: ElapsedSinceP epoch -> String Source # showList :: [ElapsedSinceP epoch] -> ShowS Source #
NFData (ElapsedSinceP e) Source # |
Instance details Defined in Data.Hourglass.Epoch Methods rnf :: ElapsedSinceP e -> () Source #
Epoch epoch => Time (ElapsedSinceP epoch) Source # |
Instance details Defined in Data.Hourglass.Epoch Methods timeFromElapsedP :: ElapsedP -> ElapsedSinceP epoch Source # timeFromElapsed :: Elapsed -> ElapsedSinceP epoch Source #
Epoch epoch => Timeable (ElapsedSinceP epoch) Source # |
Instance details Defined in Data.Hourglass.Epoch Methods timeGetElapsedP :: ElapsedSinceP epoch -> ElapsedP Source # timeGetElapsed :: ElapsedSinceP epoch -> Elapsed Source # timeGetNanoSeconds :: ElapsedSinceP epoch -> NanoSeconds Source #

# Epoch

class Epoch epoch where Source #

epoch related.

We use the well known Unix epoch as the reference timezone for doing conversion between epochs.

Each methods of this typeclass should not use the actual value, but only get the information needed from the type itself.

Methods

epochName :: epoch -> String Source #

The name of this epoch

epochDiffToUnix :: epoch -> Seconds Source #

number of seconds of difference with 1st January 1970.

a negative number means that this epoch start before the unix epoch.

Instances

Epoch WindowsEpoch Source # |
Instance details Defined in Data.Hourglass.Epoch Methods epochName :: WindowsEpoch -> String Source # epochDiffToUnix :: WindowsEpoch -> Seconds Source #
Epoch UnixEpoch Source # |
Instance details Defined in Data.Hourglass.Epoch Methods epochName :: UnixEpoch -> String Source # epochDiffToUnix :: UnixEpoch -> Seconds Source #

## standard and usual epochs

data UnixEpoch Source #

Unix Epoch, starting 1st January 1970

Constructors

UnixEpoch |

Instances

Eq UnixEpoch Source # |
Instance details Defined in Data.Hourglass.Epoch Methods (==) :: UnixEpoch -> UnixEpoch -> Bool Source # (/=) :: UnixEpoch -> UnixEpoch -> Bool Source #
Show UnixEpoch Source # |
Instance details Defined in Data.Hourglass.Epoch Methods showsPrec :: Int -> UnixEpoch -> ShowS Source # show :: UnixEpoch -> String Source # showList :: [UnixEpoch] -> ShowS Source #
Epoch UnixEpoch Source # |
Instance details Defined in Data.Hourglass.Epoch Methods epochName :: UnixEpoch -> String Source # epochDiffToUnix :: UnixEpoch -> Seconds Source #

data WindowsEpoch Source #

Windows Epoch, starting 1st January 1601

Constructors

WindowsEpoch |

Instances

Eq WindowsEpoch Source # |
Instance details Defined in Data.Hourglass.Epoch Methods (==) :: WindowsEpoch -> WindowsEpoch -> Bool Source # (/=) :: WindowsEpoch -> WindowsEpoch -> Bool Source #
Show WindowsEpoch Source # |
Instance details Defined in Data.Hourglass.Epoch Methods showsPrec :: Int -> WindowsEpoch -> ShowS Source # show :: WindowsEpoch -> String Source # showList :: [WindowsEpoch] -> ShowS Source #
Epoch WindowsEpoch Source # |
Instance details Defined in Data.Hourglass.Epoch Methods epochName :: WindowsEpoch -> String Source # epochDiffToUnix :: WindowsEpoch -> Seconds Source #