| Copyright | (c) 2019 Composewell Technologies |
|---|---|
| License | BSD3 |
| Maintainer | streamly@composewell.com |
| Stability | pre-release |
| Portability | GHC |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Streamly.Internal.Data.Time.Units
Description
Synopsis
- class TimeUnit a
- class TimeUnit64 a
- data TimeSpec = TimeSpec {}
- newtype NanoSecond64 = NanoSecond64 Int64
- newtype MicroSecond64 = MicroSecond64 Int64
- newtype MilliSecond64 = MilliSecond64 Int64
- showNanoSecond64 :: NanoSecond64 -> String
- newtype AbsTime = AbsTime TimeSpec
- toAbsTime :: TimeUnit a => a -> AbsTime
- fromAbsTime :: TimeUnit a => AbsTime -> a
- data RelTime
- toRelTime :: TimeUnit a => a -> RelTime
- fromRelTime :: TimeUnit a => RelTime -> a
- diffAbsTime :: AbsTime -> AbsTime -> RelTime
- addToAbsTime :: AbsTime -> RelTime -> AbsTime
- data RelTime64
- toRelTime64 :: TimeUnit64 a => a -> RelTime64
- fromRelTime64 :: TimeUnit64 a => RelTime64 -> a
- diffAbsTime64 :: AbsTime -> AbsTime -> RelTime64
- addToAbsTime64 :: AbsTime -> RelTime64 -> AbsTime
- showRelTime64 :: RelTime64 -> String
Time Unit Conversions
A type class for converting between time units using Integer as the
intermediate and the widest representation with a nanosecond resolution.
This system of units can represent arbitrarily large times but provides
least efficient arithmetic operations due to Integer arithmetic.
NOTE: Converting to and from units may truncate the value depending on the original value and the size and resolution of the destination unit.
A type class for converting between units of time using TimeSpec as the
intermediate representation. This system of units can represent up to ~292
billion years at nanosecond resolution with reasonably efficient arithmetic
operations.
NOTE: Converting to and from units may truncate the value depending on the original value and the size and resolution of the destination unit.
Minimal complete definition
toTimeSpec, fromTimeSpec
Instances
| TimeUnit TimeSpec Source # | |
Defined in Streamly.Internal.Data.Time.Units | |
| TimeUnit MicroSecond64 Source # | |
Defined in Streamly.Internal.Data.Time.Units | |
| TimeUnit MilliSecond64 Source # | |
Defined in Streamly.Internal.Data.Time.Units | |
| TimeUnit NanoSecond64 Source # | |
Defined in Streamly.Internal.Data.Time.Units | |
class TimeUnit64 a Source #
A type class for converting between units of time using Int64 as the
intermediate representation with a nanosecond resolution. This system of
units can represent up to ~292 years at nanosecond resolution with fast
arithmetic operations.
NOTE: Converting to and from units may truncate the value depending on the original value and the size and resolution of the destination unit.
Minimal complete definition
toNanoSecond64, fromNanoSecond64
Instances
| TimeUnit64 MicroSecond64 Source # | |
Defined in Streamly.Internal.Data.Time.Units Methods | |
| TimeUnit64 MilliSecond64 Source # | |
Defined in Streamly.Internal.Data.Time.Units Methods | |
| TimeUnit64 NanoSecond64 Source # | |
Defined in Streamly.Internal.Data.Time.Units Methods | |
Time Units
Data type to represent practically large quantities of time efficiently. It can represent time up to ~292 billion years at nanosecond resolution.
Instances
| Storable TimeSpec Source # | |
Defined in Streamly.Internal.Data.Time.TimeSpec Methods sizeOf :: TimeSpec -> Int Source # alignment :: TimeSpec -> Int Source # peekElemOff :: Ptr TimeSpec -> Int -> IO TimeSpec Source # pokeElemOff :: Ptr TimeSpec -> Int -> TimeSpec -> IO () Source # peekByteOff :: Ptr b -> Int -> IO TimeSpec Source # pokeByteOff :: Ptr b -> Int -> TimeSpec -> IO () Source # | |
| Num TimeSpec Source # | |
Defined in Streamly.Internal.Data.Time.TimeSpec Methods (+) :: TimeSpec -> TimeSpec -> TimeSpec Source # (-) :: TimeSpec -> TimeSpec -> TimeSpec Source # (*) :: TimeSpec -> TimeSpec -> TimeSpec Source # negate :: TimeSpec -> TimeSpec Source # abs :: TimeSpec -> TimeSpec Source # signum :: TimeSpec -> TimeSpec Source # fromInteger :: Integer -> TimeSpec Source # | |
| Read TimeSpec Source # | |
| Show TimeSpec Source # | |
| Eq TimeSpec Source # | |
| Ord TimeSpec Source # | |
Defined in Streamly.Internal.Data.Time.TimeSpec | |
| TimeUnit TimeSpec Source # | |
Defined in Streamly.Internal.Data.Time.Units | |
newtype NanoSecond64 Source #
An Int64 time representation with a nanosecond resolution. It can
represent time up to ~292 years.
Constructors
| NanoSecond64 Int64 |
Instances
newtype MicroSecond64 Source #
An Int64 time representation with a microsecond resolution.
It can represent time up to ~292,000 years.
Constructors
| MicroSecond64 Int64 |
Instances
newtype MilliSecond64 Source #
An Int64 time representation with a millisecond resolution.
It can represent time up to ~292 million years.
Constructors
| MilliSecond64 Int64 |
Instances
showNanoSecond64 :: NanoSecond64 -> String Source #
Convert nanoseconds to a string showing time in an appropriate unit.
Absolute times (using TimeSpec)
Absolute times are relative to a predefined epoch in time. AbsTime
represents times using TimeSpec which can represent times up to ~292
billion years at a nanosecond resolution.
Instances
| Show AbsTime Source # | |
| Eq AbsTime Source # | |
| Ord AbsTime Source # | |
Defined in Streamly.Internal.Data.Time.Units | |
Relative times (using TimeSpec)
Instances
| Num RelTime Source # | |
Defined in Streamly.Internal.Data.Time.Units | |
| Read RelTime Source # | |
| Show RelTime Source # | |
| Eq RelTime Source # | |
| Ord RelTime Source # | |
Defined in Streamly.Internal.Data.Time.Units | |
fromRelTime :: TimeUnit a => RelTime -> a Source #
Relative times (using NanoSecond64)
Relative times are relative to some arbitrary point of time. Unlike
AbsTime they are not relative to a predefined epoch.
Instances
toRelTime64 :: TimeUnit64 a => a -> RelTime64 Source #
Convert a TimeUnit to a relative time.
fromRelTime64 :: TimeUnit64 a => RelTime64 -> a Source #
Convert relative time to a TimeUnit.
diffAbsTime64 :: AbsTime -> AbsTime -> RelTime64 Source #
Difference between two absolute points of time.
showRelTime64 :: RelTime64 -> String Source #