Copyright | (c) 2019 Composewell Technologies |
---|---|
License | BSD3 |
Maintainer | streamly@composewell.com |
Stability | pre-release |
Portability | GHC |
Safe Haskell | None |
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 MilliSecond64 Source # | |
Defined in Streamly.Internal.Data.Time.Units | |
TimeUnit MicroSecond64 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 MilliSecond64 Source # | |
Defined in Streamly.Internal.Data.Time.Units Methods | |
TimeUnit64 MicroSecond64 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
Eq TimeSpec Source # | |
Num TimeSpec Source # | |
Defined in Streamly.Internal.Data.Time.TimeSpec | |
Ord TimeSpec Source # | |
Defined in Streamly.Internal.Data.Time.TimeSpec | |
Read TimeSpec Source # | |
Show TimeSpec Source # | |
Storable 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.
Relative times (using TimeSpec)
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 #