Copyright | (c) 2019 Harendra Kumar |
---|---|
License | BSD3 |
Maintainer | streamly@composewell.com |
Stability | experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
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.
toTimeSpec, fromTimeSpec
Instances
TimeUnit TimeSpec Source # | |
Defined in Streamly.Internal.Data.Time.Units toTimeSpec :: TimeSpec -> TimeSpec fromTimeSpec :: TimeSpec -> TimeSpec | |
TimeUnit MilliSecond64 Source # | |
Defined in Streamly.Internal.Data.Time.Units toTimeSpec :: MilliSecond64 -> TimeSpec | |
TimeUnit MicroSecond64 Source # | |
Defined in Streamly.Internal.Data.Time.Units toTimeSpec :: MicroSecond64 -> TimeSpec | |
TimeUnit NanoSecond64 Source # | |
Defined in Streamly.Internal.Data.Time.Units toTimeSpec :: NanoSecond64 -> TimeSpec fromTimeSpec :: TimeSpec -> NanoSecond64 |
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.
toNanoSecond64, fromNanoSecond64
Instances
TimeUnit64 MilliSecond64 Source # | |
TimeUnit64 MicroSecond64 Source # | |
TimeUnit64 NanoSecond64 Source # | |
Defined in Streamly.Internal.Data.Time.Units |
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 # | |
Ord TimeSpec Source # | |
Defined in Streamly.Internal.Data.Time.Units | |
Read TimeSpec Source # | |
Show TimeSpec Source # | |
Storable TimeSpec Source # | |
Defined in Streamly.Internal.Data.Time.Clock | |
TimeUnit TimeSpec Source # | |
Defined in Streamly.Internal.Data.Time.Units toTimeSpec :: TimeSpec -> TimeSpec fromTimeSpec :: TimeSpec -> TimeSpec |
newtype NanoSecond64 Source #
An Int64
time representation with a nanosecond resolution. It can
represent time up to ~292 years.
Instances
newtype MicroSecond64 Source #
An Int64
time representation with a microsecond resolution.
It can represent time up to ~292,000 years.
Instances
newtype MilliSecond64 Source #
An Int64
time representation with a millisecond resolution.
It can represent time up to ~292 million years.
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
Bounded RelTime64 Source # | |
Enum RelTime64 Source # | |
Defined in Streamly.Internal.Data.Time.Units succ :: RelTime64 -> RelTime64 # pred :: RelTime64 -> RelTime64 # fromEnum :: RelTime64 -> Int # enumFrom :: RelTime64 -> [RelTime64] # enumFromThen :: RelTime64 -> RelTime64 -> [RelTime64] # enumFromTo :: RelTime64 -> RelTime64 -> [RelTime64] # enumFromThenTo :: RelTime64 -> RelTime64 -> RelTime64 -> [RelTime64] # | |
Eq RelTime64 Source # | |
Integral RelTime64 Source # | |
Defined in Streamly.Internal.Data.Time.Units | |
Num RelTime64 Source # | |
Defined in Streamly.Internal.Data.Time.Units | |
Ord RelTime64 Source # | |
Defined in Streamly.Internal.Data.Time.Units | |
Read RelTime64 Source # | |
Real RelTime64 Source # | |
Defined in Streamly.Internal.Data.Time.Units toRational :: RelTime64 -> Rational # | |
Show RelTime64 Source # | |
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 #