Data.Hourglass.Epoch

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 #

A number of seconds elapsed since an epoch.

Constructors

ElapsedSince Seconds |

#### Instances

Instances details

NFData (ElapsedSince epoch) # |
Instance details Defined in Data.Hourglass.Epoch Methods rnf :: ElapsedSince epoch -> () #
Data epoch => Data (ElapsedSince epoch) # |
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) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (ElapsedSince epoch) # toConstr :: ElapsedSince epoch -> Constr # dataTypeOf :: ElapsedSince epoch -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (ElapsedSince epoch)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (ElapsedSince epoch)) # gmapT :: (forall b. Data b => b -> b) -> ElapsedSince epoch -> ElapsedSince epoch # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ElapsedSince epoch -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ElapsedSince epoch -> r # gmapQ :: (forall d. Data d => d -> u) -> ElapsedSince epoch -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> ElapsedSince epoch -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> ElapsedSince epoch -> m (ElapsedSince epoch) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ElapsedSince epoch -> m (ElapsedSince epoch) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ElapsedSince epoch -> m (ElapsedSince epoch) #
Num (ElapsedSince epoch) # |
Instance details Defined in Data.Hourglass.Epoch Methods (+) :: ElapsedSince epoch -> ElapsedSince epoch -> ElapsedSince epoch # (-) :: ElapsedSince epoch -> ElapsedSince epoch -> ElapsedSince epoch # (*) :: ElapsedSince epoch -> ElapsedSince epoch -> ElapsedSince epoch # negate :: ElapsedSince epoch -> ElapsedSince epoch # abs :: ElapsedSince epoch -> ElapsedSince epoch # signum :: ElapsedSince epoch -> ElapsedSince epoch # fromInteger :: Integer -> ElapsedSince epoch #
Read (ElapsedSince epoch) # |
Instance details Defined in Data.Hourglass.Epoch Methods readsPrec :: Int -> ReadS (ElapsedSince epoch) # readList :: ReadS [ElapsedSince epoch] # readPrec :: ReadPrec (ElapsedSince epoch) # readListPrec :: ReadPrec [ElapsedSince epoch] #
Show (ElapsedSince epoch) # |
Instance details Defined in Data.Hourglass.Epoch Methods showsPrec :: Int -> ElapsedSince epoch -> ShowS # show :: ElapsedSince epoch -> String # showList :: [ElapsedSince epoch] -> ShowS #
Eq (ElapsedSince epoch) # |
Instance details Defined in Data.Hourglass.Epoch Methods (==) :: ElapsedSince epoch -> ElapsedSince epoch -> Bool # (/=) :: ElapsedSince epoch -> ElapsedSince epoch -> Bool #
Ord (ElapsedSince epoch) # |
Instance details Defined in Data.Hourglass.Epoch Methods compare :: ElapsedSince epoch -> ElapsedSince epoch -> Ordering # (<) :: ElapsedSince epoch -> ElapsedSince epoch -> Bool # (<=) :: ElapsedSince epoch -> ElapsedSince epoch -> Bool # (>) :: ElapsedSince epoch -> ElapsedSince epoch -> Bool # (>=) :: ElapsedSince epoch -> ElapsedSince epoch -> Bool # max :: ElapsedSince epoch -> ElapsedSince epoch -> ElapsedSince epoch # min :: ElapsedSince epoch -> ElapsedSince epoch -> ElapsedSince epoch #
Epoch epoch => Time (ElapsedSince epoch) # |
Instance details Defined in Data.Hourglass.Epoch Methods timeFromElapsedP :: ElapsedP -> ElapsedSince epoch # timeFromElapsed :: Elapsed -> ElapsedSince epoch #
Epoch epoch => Timeable (ElapsedSince epoch) # |
Instance details Defined in Data.Hourglass.Epoch Methods timeGetElapsedP :: ElapsedSince epoch -> ElapsedP # timeGetElapsed :: ElapsedSince epoch -> Elapsed # timeGetNanoSeconds :: ElapsedSince epoch -> NanoSeconds #

data ElapsedSinceP epoch #

A number of seconds and nanoseconds elapsed since an epoch.

Constructors

ElapsedSinceP !(ElapsedSince epoch) !NanoSeconds |

#### Instances

Instances details

NFData (ElapsedSinceP e) # |
Instance details Defined in Data.Hourglass.Epoch Methods rnf :: ElapsedSinceP e -> () #
Data epoch => Data (ElapsedSinceP epoch) # |
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) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (ElapsedSinceP epoch) # toConstr :: ElapsedSinceP epoch -> Constr # dataTypeOf :: ElapsedSinceP epoch -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (ElapsedSinceP epoch)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (ElapsedSinceP epoch)) # gmapT :: (forall b. Data b => b -> b) -> ElapsedSinceP epoch -> ElapsedSinceP epoch # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ElapsedSinceP epoch -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ElapsedSinceP epoch -> r # gmapQ :: (forall d. Data d => d -> u) -> ElapsedSinceP epoch -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> ElapsedSinceP epoch -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> ElapsedSinceP epoch -> m (ElapsedSinceP epoch) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ElapsedSinceP epoch -> m (ElapsedSinceP epoch) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ElapsedSinceP epoch -> m (ElapsedSinceP epoch) #
Num (ElapsedSinceP e) # |
Instance details Defined in Data.Hourglass.Epoch Methods (+) :: ElapsedSinceP e -> ElapsedSinceP e -> ElapsedSinceP e # (-) :: ElapsedSinceP e -> ElapsedSinceP e -> ElapsedSinceP e # (*) :: ElapsedSinceP e -> ElapsedSinceP e -> ElapsedSinceP e # negate :: ElapsedSinceP e -> ElapsedSinceP e # abs :: ElapsedSinceP e -> ElapsedSinceP e # signum :: ElapsedSinceP e -> ElapsedSinceP e # fromInteger :: Integer -> ElapsedSinceP e #
Read (ElapsedSinceP epoch) # |
Instance details Defined in Data.Hourglass.Epoch Methods readsPrec :: Int -> ReadS (ElapsedSinceP epoch) # readList :: ReadS [ElapsedSinceP epoch] # readPrec :: ReadPrec (ElapsedSinceP epoch) # readListPrec :: ReadPrec [ElapsedSinceP epoch] #
Show (ElapsedSinceP epoch) # |
Instance details Defined in Data.Hourglass.Epoch Methods showsPrec :: Int -> ElapsedSinceP epoch -> ShowS # show :: ElapsedSinceP epoch -> String # showList :: [ElapsedSinceP epoch] -> ShowS #
Eq (ElapsedSinceP epoch) # |
Instance details Defined in Data.Hourglass.Epoch Methods (==) :: ElapsedSinceP epoch -> ElapsedSinceP epoch -> Bool # (/=) :: ElapsedSinceP epoch -> ElapsedSinceP epoch -> Bool #
Ord (ElapsedSinceP epoch) # |
Instance details Defined in Data.Hourglass.Epoch Methods compare :: ElapsedSinceP epoch -> ElapsedSinceP epoch -> Ordering # (<) :: ElapsedSinceP epoch -> ElapsedSinceP epoch -> Bool # (<=) :: ElapsedSinceP epoch -> ElapsedSinceP epoch -> Bool # (>) :: ElapsedSinceP epoch -> ElapsedSinceP epoch -> Bool # (>=) :: ElapsedSinceP epoch -> ElapsedSinceP epoch -> Bool # max :: ElapsedSinceP epoch -> ElapsedSinceP epoch -> ElapsedSinceP epoch # min :: ElapsedSinceP epoch -> ElapsedSinceP epoch -> ElapsedSinceP epoch #
Epoch epoch => Time (ElapsedSinceP epoch) # |
Instance details Defined in Data.Hourglass.Epoch Methods timeFromElapsedP :: ElapsedP -> ElapsedSinceP epoch # timeFromElapsed :: Elapsed -> ElapsedSinceP epoch #
Epoch epoch => Timeable (ElapsedSinceP epoch) # |
Instance details Defined in Data.Hourglass.Epoch Methods timeGetElapsedP :: ElapsedSinceP epoch -> ElapsedP # timeGetElapsed :: ElapsedSinceP epoch -> Elapsed # timeGetNanoSeconds :: ElapsedSinceP epoch -> NanoSeconds #

# Epoch

class Epoch epoch where #

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 #

The name of this epoch

epochDiffToUnix :: epoch -> Seconds #

number of seconds of difference with 1st January 1970.

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

#### Instances

Instances details

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

## standard and usual epochs

data UnixEpoch #

Unix Epoch, starting 1st January 1970

Constructors

UnixEpoch |

#### Instances

Instances details

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

data WindowsEpoch #

Windows Epoch, starting 1st January 1601

Constructors

WindowsEpoch |

#### Instances

Instances details

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