Safe Haskell | None |
---|---|
Language | Haskell2010 |
Temporal.Duration
Description
Convenient units of time for use with timers and timeouts.
Anything longer than a week (Months, Years) becomes ambiguous because they are variable length. For example, a month can be 28, 29, 30, or 31 days.
If you need to represent a duration as years or months, you may want to use the time
library to normalize against a specific time zone and then convert the difference
between now and then into a Duration.
Alternatively, consider using Temporal's scheduling features to schedule a workflow to run at one or more specific times in the future.
Synopsis
- data Duration
- durationSeconds :: Duration -> Int64
- durationNanoseconds :: Duration -> Int32
- mkDuration :: Int64 -> Int32 -> Duration
- addDurations :: Duration -> Duration -> Duration
- diffTimeToDuration :: DiffTime -> Duration
- nominalDiffTimeToDuration :: NominalDiffTime -> Duration
- nanoseconds :: Integer -> Duration
- microseconds :: Integer -> Duration
- milliseconds :: Int64 -> Duration
- seconds :: Int64 -> Duration
- minutes :: Int32 -> Duration
- hours :: Int32 -> Duration
- days :: Int32 -> Duration
- weeks :: Int32 -> Duration
- infinity :: Duration
- durationFromProto :: Duration -> Duration
- durationToProto :: Duration -> Duration
- durationToMilliseconds :: Duration -> Double
Documentation
A duration of time. Durations are always positive.
Instances
FromJSON Duration Source # | |
Defined in Temporal.Duration | |
ToJSON Duration Source # | Generated output always contains 0, 3, 6, or 9 fractional digits, depending on required precision, followed by the suffix "s". Accepted are any fractional digits (also none) as long as they fit into nano-seconds precision and the suffix "s" is required. |
Monoid Duration Source # | |
Semigroup Duration Source # | |
Data Duration Source # | |
Defined in Temporal.Duration Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Duration -> c Duration # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Duration # toConstr :: Duration -> Constr # dataTypeOf :: Duration -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Duration) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Duration) # gmapT :: (forall b. Data b => b -> b) -> Duration -> Duration # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Duration -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Duration -> r # gmapQ :: (forall d. Data d => d -> u) -> Duration -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Duration -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Duration -> m Duration # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Duration -> m Duration # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Duration -> m Duration # | |
Show Duration Source # | |
Eq Duration Source # | |
Ord Duration Source # | |
Defined in Temporal.Duration | |
Lift Duration Source # | |
durationSeconds :: Duration -> Int64 Source #
durationNanoseconds :: Duration -> Int32 Source #
addDurations :: Duration -> Duration -> Duration Source #
Add two durations together. Durations are subject to integer overflow.
nominalDiffTimeToDuration :: NominalDiffTime -> Duration Source #
Convert a NominalDiffTime
to a Duration
.
N.B. negative NominalDiffTime
values will be clamped to 0 (i.e. Duration
will be 0)
in order to avoid the conversion of negative NominalDiffTime
values to extremely large
Word64 values.
A Duration
representing the maximum possible length of time. (Approximately 132 years.)