The OpenD Programming Language

Interval

Represents an interval of time.

An Interval has a starting point and an end point. The interval of time is therefore the time starting at the starting point up to, but not including, the end point. e.g.

[January 5th, 2010 - March 10th, 2010)
[05:00:30 - 12:00:00)
[1982-01-04T08:59:00 - 2010-07-04T12:00:00)

A range can be obtained from an Interval, allowing iteration over that interval, with the exact time points which are iterated over depending on the function which generates the range.

struct Interval (
TP
) {}

Constructors

this
this(TP begin, U end)
this
this(TP begin, D duration)

Members

Functions

bwdRange
IntervalRange!(TP, Direction.bwd) bwdRange(TP delegate(scope const TP) func, PopFirst popFirst)

Returns a range which iterates backwards over the interval, starting at end, using func to generate each successive time point.

contains
bool contains(TP timePoint)

Whether the given time point is within this interval.

contains
bool contains(Interval interval)

Whether the given interval is completely within this interval.

contains
bool contains(PosInfInterval!TP interval)

Whether the given interval is completely within this interval.

contains
bool contains(NegInfInterval!TP interval)

Whether the given interval is completely within this interval.

expand
void expand(D duration, Direction dir)

Expands the interval forwards and/or backwards in time. Effectively, it does begin -= duration and/or end += duration. Whether it expands forwards and/or backwards in time is determined by dir.

expand
void expand(T years, T months, AllowDayOverflow allowOverflow, Direction dir)

Expands the interval forwards and/or backwards in time. Effectively, it subtracts the given number of months/years from begin and adds them to end. Whether it expands forwards and/or backwards in time is determined by dir.

fwdRange
IntervalRange!(TP, Direction.fwd) fwdRange(TP delegate(scope const TP) func, PopFirst popFirst)

Returns a range which iterates forward over the interval, starting at begin, using func to generate each successive time point.

intersection
Interval intersection(Interval interval)

Returns the intersection of two intervals

intersection
Interval intersection(PosInfInterval!TP interval)

Returns the intersection of two intervals

intersection
Interval intersection(NegInfInterval!TP interval)

Returns the intersection of two intervals

intersects
bool intersects(Interval interval)

Whether the given interval overlaps this interval.

intersects
bool intersects(PosInfInterval!TP interval)

Whether the given interval overlaps this interval.

intersects
bool intersects(NegInfInterval!TP interval)

Whether the given interval overlaps this interval.

isAdjacent
bool isAdjacent(Interval interval)

Whether the given interval is adjacent to this interval.

isAdjacent
bool isAdjacent(PosInfInterval!TP interval)

Whether the given interval is adjacent to this interval.

isAdjacent
bool isAdjacent(NegInfInterval!TP interval)

Whether the given interval is adjacent to this interval.

isAfter
bool isAfter(TP timePoint)

Whether this interval is after the given time point.

isAfter
bool isAfter(Interval interval)

Whether this interval is after the given interval and does not intersect it.

isAfter
bool isAfter(PosInfInterval!TP interval)

Whether this interval is after the given interval and does not intersect it.

isAfter
bool isAfter(NegInfInterval!TP interval)

Whether this interval is after the given interval and does not intersect it.

isBefore
bool isBefore(TP timePoint)

Whether this interval is before the given time point.

isBefore
bool isBefore(Interval interval)

Whether this interval is before the given interval and does not intersect with it.

isBefore
bool isBefore(PosInfInterval!TP interval)

Whether this interval is before the given interval and does not intersect with it.

isBefore
bool isBefore(NegInfInterval!TP interval)

Whether this interval is before the given interval and does not intersect with it.

merge
Interval merge(Interval interval)

Returns the union of two intervals

merge
PosInfInterval!TP merge(PosInfInterval!TP interval)

Returns the union of two intervals

merge
NegInfInterval!TP merge(NegInfInterval!TP interval)

Returns the union of two intervals

opAssign
Interval opAssign(Interval rhs)
opAssign
Interval opAssign(Interval rhs)
shift
void shift(D duration)

Shifts the interval forward or backwards in time by the given duration (a positive duration shifts the interval forward; a negative duration shifts it backward). Effectively, it does begin += duration and end += duration.

shift
void shift(T years, T months, AllowDayOverflow allowOverflow)

Shifts the interval forward or backwards in time by the given number of years and/or months (a positive number of years and months shifts the interval forward; a negative number shifts it backward). It adds the years the given years and months to both begin and end. It effectively calls add!"years"() and then add!"months"() on begin and end with the given number of years and months.

span
Interval span(Interval interval)

Returns an interval that covers from the earliest time point of two intervals up to (but not including) the latest time point of two intervals.

span
PosInfInterval!TP span(PosInfInterval!TP interval)

Returns an interval that covers from the earliest time point of two intervals up to (but not including) the latest time point of two intervals.

span
NegInfInterval!TP span(NegInfInterval!TP interval)

Returns an interval that covers from the earliest time point of two intervals up to (but not including) the latest time point of two intervals.

toString
string toString()
void toString(Writer w)

Converts this interval to a string.

Properties

begin
TP begin [@property getter]

The starting point of the interval. It is included in the interval.

begin
TP begin [@property setter]

The starting point of the interval. It is included in the interval.

empty
bool empty [@property getter]

Whether the interval's length is 0, that is, whether begin == end.

end
TP end [@property getter]

The end point of the interval. It is excluded from the interval.

end
TP end [@property setter]

The end point of the interval. It is excluded from the interval.

length
auto length [@property getter]

Returns the duration between begin and end.

Meta