Copyright | Copyright © 2021 Kadena LLC. |
---|---|
License | MIT |
Maintainer | Lars Kuhtz <lars@kadena.io> |
Stability | experimental |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Pact.Time
Description
A minimal time library for usage with the Pact Smart Contract Language.
The focus of this library is on minimality, performance, and binary level stability. Time is represented as 64-bit integral value that counts nominal micro-seconds since the modified Julian date epoch (MJD). The implementation ignores leap seconds.
While the library can parse date-time values with time zones, internally all date-times are represented as UTC and formatting only supports UTC. Only the default English language locale is supported.
Details about supported formats can be found in the Pact Language Reference.
Synopsis
- newtype NominalDiffTime = NominalDiffTime {}
- toMicroseconds :: NominalDiffTime -> Micros
- fromMicroseconds :: Micros -> NominalDiffTime
- toSeconds :: NominalDiffTime -> Decimal
- fromSeconds :: Decimal -> NominalDiffTime
- nominalDay :: NominalDiffTime
- data UTCTime
- getCurrentTime :: IO UTCTime
- day :: Lens' UTCTime ModifiedJulianDay
- dayTime :: Lens' UTCTime NominalDiffTime
- fromDayAndDayTime :: ModifiedJulianDay -> NominalDiffTime -> UTCTime
- toPosixTimestampMicros :: UTCTime -> Micros
- fromPosixTimestampMicros :: Micros -> UTCTime
- posixEpoch :: UTCTime
- mjdEpoch :: UTCTime
- parseTime :: String -> String -> Maybe UTCTime
- formatTime :: FormatTime t => String -> t -> String
- class AdditiveSemigroup g where
- plus :: g -> g -> g
- class AdditiveSemigroup g => AdditiveMonoid g where
- zero :: g
- class AdditiveMonoid g => AdditiveGroup g where
- (^-^) :: AdditiveAbelianGroup g => g -> g -> g
- (^+^) :: AdditiveAbelianSemigroup g => g -> g -> g
- (.+^) :: (AdditiveAbelianGroup (Diff t), LeftTorsor t) => t -> Diff t -> t
- (^+.) :: (AdditiveAbelianGroup (Diff t), LeftTorsor t) => Diff t -> t -> t
- (.-.) :: (AdditiveAbelianGroup (Diff t), LeftTorsor t) => t -> t -> Diff t
- (.-^) :: (AdditiveAbelianGroup (Diff t), LeftTorsor t) => t -> Diff t -> t
- (*^) :: Integral a => a -> NominalDiffTime -> NominalDiffTime
NominalDiffTime
newtype NominalDiffTime Source #
A time interval as measured by UTC, that does not take leap-seconds into account.
Constructors
NominalDiffTime | |
Fields |
Instances
toMicroseconds :: NominalDiffTime -> Micros Source #
Convert from NominalDiffTime
to a 64-bit representation of microseconds.
fromMicroseconds :: Micros -> NominalDiffTime Source #
Convert from a 64-bit representation of microseconds to NominalDiffTime
.
toSeconds :: NominalDiffTime -> Decimal Source #
Convert from NominalDiffTime
to a DecimalRaw
representation of seconds.
fromSeconds :: Decimal -> NominalDiffTime Source #
Convert from DecimalRaw
representation of seconds to NominalDiffTime
.
The result is rounded using banker's method, i.e. remainders of 0.5 a rounded to the next even integer.
nominalDay :: NominalDiffTime Source #
The nominal length of a day: precisely 86400 SI seconds.
UTCTime
UTCTime with microseconds precision. Internally it is represented as 64-bit count nominal microseconds since MJD Epoch.
This implementation ignores leap seconds. Time differences are measured as
nominal time, with a nominal day having exaxtly 24 * 60 * 60
SI seconds. As
a consequence the difference between two dates as computed by this module is
generally equal or smaller than what is actually measured by a clock.
Instances
FromJSON UTCTime Source # | |
Defined in Pact.Time.Format.Internal | |
ToJSON UTCTime Source # | |
Generic UTCTime Source # | |
Read UTCTime Source # | |
Show UTCTime Source # | |
Serialize UTCTime Source # | |
NFData UTCTime Source # | |
Defined in Pact.Time.Internal | |
Eq UTCTime Source # | |
Ord UTCTime Source # | |
LeftTorsor UTCTime Source # | |
type Rep UTCTime Source # | |
Defined in Pact.Time.Internal type Rep UTCTime = D1 ('MetaData "UTCTime" "Pact.Time.Internal" "pact-time-0.3.0.1-48iocCFVBhNFn5qKDoNmak" 'True) (C1 ('MetaCons "UTCTime" 'PrefixI 'True) (S1 ('MetaSel ('Just "_utcTime") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 NominalDiffTime))) | |
type Diff UTCTime Source # | |
Defined in Pact.Time.Internal |
day :: Lens' UTCTime ModifiedJulianDay Source #
The date of a UTCTime value represented as modified Julian Day
.
dayTime :: Lens' UTCTime NominalDiffTime Source #
The day time of a UTCTime
value represented as NominalDiffTime
since
00:00:00
of that respective day.
fromDayAndDayTime :: ModifiedJulianDay -> NominalDiffTime -> UTCTime Source #
Create a UTCTime
from a date and a daytime. The date is represented
as modified Julian Day
and the day time is represented as
NominalDiffTime
since '00:00:00' of the respective day.
Note that this implementation does not support representation of leap seconds.
posixEpoch :: UTCTime Source #
The POSIX Epoch represented as UTCTime.
Formatting and Parsing
formatTime :: FormatTime t => String -> t -> String Source #
Reexports
class AdditiveSemigroup g where #
Additive Semigroup
(a `plus` b) `plus` c == a `plus` (b `plus` c)
Instances
class AdditiveSemigroup g => AdditiveMonoid g where #
Additive Monoid
a `plus` zero == a
zero `plus` a == a
Instances
AdditiveMonoid Int16 | |
Defined in Numeric.Additive | |
AdditiveMonoid Int32 | |
Defined in Numeric.Additive | |
AdditiveMonoid Int64 | |
Defined in Numeric.Additive | |
AdditiveMonoid Int8 | |
Defined in Numeric.Additive | |
AdditiveMonoid Rational | |
Defined in Numeric.Additive | |
AdditiveMonoid Word16 | |
Defined in Numeric.Additive | |
AdditiveMonoid Word32 | |
Defined in Numeric.Additive | |
AdditiveMonoid Word64 | |
Defined in Numeric.Additive | |
AdditiveMonoid Word8 | |
Defined in Numeric.Additive | |
AdditiveMonoid Word128 | |
Defined in Numeric.Additive | |
AdditiveMonoid Word256 | |
Defined in Numeric.Additive | |
AdditiveMonoid NominalDiffTime Source # | |
Defined in Pact.Time.Internal Methods zero :: NominalDiffTime # | |
AdditiveMonoid Integer | |
Defined in Numeric.Additive | |
AdditiveMonoid Natural | |
Defined in Numeric.Additive | |
AdditiveMonoid Int | |
Defined in Numeric.Additive | |
AdditiveMonoid Word | |
Defined in Numeric.Additive |
class AdditiveMonoid g => AdditiveGroup g where #
Additive Group
a `plus` inverse a == zero
inverse a `plus` a == zero
Instances
(^-^) :: AdditiveAbelianGroup g => g -> g -> g infix 6 #
(^+^) :: AdditiveAbelianSemigroup g => g -> g -> g infixl 6 #
(.+^) :: (AdditiveAbelianGroup (Diff t), LeftTorsor t) => t -> Diff t -> t infixl 6 #
(^+.) :: (AdditiveAbelianGroup (Diff t), LeftTorsor t) => Diff t -> t -> t infixl 6 #
(.-.) :: (AdditiveAbelianGroup (Diff t), LeftTorsor t) => t -> t -> Diff t infix 6 #
(.-^) :: (AdditiveAbelianGroup (Diff t), LeftTorsor t) => t -> Diff t -> t infixl 6 #
(*^) :: Integral a => a -> NominalDiffTime -> NominalDiffTime Source #