Temporal.Interval
- Package
- purescript-temporal
- Repository
- philippedev101/purescript-temporal
Half-open intervals [start, end) with Allen's interval algebra.
All intervals use half-open semantics: the start is included, the end is excluded. This is the standard convention for temporal intervals and composes cleanly — adjacent intervals share a boundary with no gap or overlap.
For date ranges, use [Jan 1, Feb 1) to mean "all of January" rather
than the closed [Jan 1, Jan 31].
#Interval Source
newtype Interval aA half-open interval [start, end). The start is included, the end is
excluded. An interval where start >= end is considered empty/invalid
and cannot be constructed via interval.
Constructors
Interval { end :: a, start :: a }
Instances
(EncodeJson a) => EncodeJson (Interval a)(DecodeJson a) => DecodeJson (Interval a)(Eq a) => Eq (Interval a)(Show a) => Show (Interval a)
#unsafeInterval Source
unsafeInterval :: forall a. a -> a -> Interval aConstruct an interval without validation. The caller must ensure
start < end.
#Relation Source
data RelationAllen's 13 interval relations. Any two non-empty intervals are in exactly one of these relations.
Given intervals X and Y:
Before : X entirely before Y (gap between)
Meets : X.end == Y.start (adjacent, X first)
Overlaps : X starts first, X.end inside Y
Starts : same start, X ends before Y
During : X fully inside Y
Finishes : X starts after Y.start, same end
Equals : identical start and end
FinishedBy : inverse of Finishes
Contains : inverse of During
StartedBy : inverse of Starts
OverlappedBy : inverse of Overlaps
MetBy : inverse of Meets
After : inverse of Before
Constructors
Instances
#difference Source
difference :: forall a. Ord a => Interval a -> Interval a -> Array (Interval a)The parts of the first interval not in the second. Returns 0, 1, or 2 intervals.
difference [1, 10) [3, 7) == [ [1, 3), [7, 10) ] -- hole punched
difference [1, 5) [3, 7) == [ [1, 3) ] -- trimmed
difference [5, 7) [1, 10) == [] -- fully consumed
- Modules
- Temporal.
Diff - Temporal.
Display - Temporal.
Duration - Temporal.
Duration. Extra - Temporal.
Format. Html - Temporal.
Instant - Temporal.
Instant. Extra - Temporal.
Internal. Options - Temporal.
Internal. Types - Temporal.
Internal. Unsafe - Temporal.
Interval - Temporal.
Interval. Duration - Temporal.
Interval. Set - Temporal.
Now - Temporal.
PlainDate - Temporal.
PlainDate. Boundary - Temporal.
PlainDate. Extra - Temporal.
PlainDate. Weekday - Temporal.
PlainDateTime - Temporal.
PlainDateTime. Extra - Temporal.
PlainMonthDay - Temporal.
PlainTime - Temporal.
PlainTime. Extra - Temporal.
PlainYearMonth - Temporal.
PlainYearMonth. Extra - Temporal.
Predicate - Temporal.
TimeDuration - Temporal.
ZonedDateTime - Temporal.
ZonedDateTime. Boundary - Temporal.
ZonedDateTime. Extra