| Copyright | (c) Lackmann Phymetric |
|---|---|
| License | GPL-3 |
| Maintainer | olaf.klinke@phymetric.de |
| Stability | experimental |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Data.Interval.Time
Description
This module defines datatypes for closed intervals
with end points on the UTCTime axis.
Synopsis
- data MinuteInterval (n :: Nat)
- fromEndTime :: KnownNat n => Proxy n -> ZonedTime -> MinuteInterval n
- ubZoned :: MinuteInterval n -> ZonedTime
- type Min10 = MinuteInterval 10
- until10 :: ZonedTime -> Min10
- type Min15 = MinuteInterval 15
- until15 :: ZonedTime -> Min15
Time intervals of statically known length
data MinuteInterval (n :: Nat) Source #
Closed time intervals of statically known length in minutes.
Although such intervals are completely determined by the end time of type ZonedTime
that was used for construction,
we cache lb and ub als lazy fields of type UTCTime to speed up Interval queries.
Since: 0.2.1
Instances
fromEndTime :: KnownNat n => Proxy n -> ZonedTime -> MinuteInterval n Source #
Smart constructor.
ub(fromEndTimep z) ==zonedTimeToUTCzubZoned(fromEndTimep z) == z
ubZoned :: MinuteInterval n -> ZonedTime Source #
Retrieve the upper bound that was used in construction, see fromEndTime.
Time intervals of length 10 minutes
type Min10 = MinuteInterval 10 Source #
Time intervals of length 10 minutes. In logging applications, aggregate values (e.g. averages, sums, ...) are often taken over a period of 10 minutes and associated with the time when the aggregation was computed.
To create your custom aggregate data type, pair this time interval with the aggregate value, like follows.
data SumOver10Minutes s = Aggregate {
aggregateValue :: s,
aggregatedOver :: Min10
}
instance Interval UTCTime (SumOver10Minutes s) where
lb = lb.aggregatedOver
ub = ub.aggregatedOver
compositeAggregate :: (Interval UTCTime i, Monoid s, Foldable f, IntersectionQuery f UTCTime t) =>
i -> t (SumOver10Minutes s) -> s
compositeAggregate i = foldMap aggregateValue . getProperIntersects i
Since: 0.2.1
Time intervals of length 15 minutes
type Min15 = MinuteInterval 15 Source #
Time intervals comprising quarter of an hour.
Since: 0.2.1