Struct std.datetime.IntervalRange
A range over an .Interval, Interval.
is only ever constructed by IntervalRange.Interval, Interval. However, when
it is constructed, it is given a function, , which is used to
generate the time points which are iterated over. func takes a time
point and returns a time point of the same type. For instance,
to iterate over all of the days in
the funcinterval , pass a function to Interval!Date.Interval, Interval's fwdRange
where that function took a Date and returned a Date which was one
day later. That function would then be used by 's
IntervalRange to iterate over the Dates in the popFrontinterval.
If dir == , then a range iterates forward in time, whereas
if Direction.fwddir == , then it iterates backwards in time. So, if
Direction.bwddir == then Direction.fwd, whereas if
front == interval.begindir == then Direction.bwd. front == interval.end must
generate a time point going in the proper funcdirection of iteration, or a
DateTimeException will be thrown. So, to iterate forward in
time, the time point that generates must be later in time than the
one passed to it. If it's either identical or earlier in time, then a
funcDateTimeException will be thrown. To iterate backwards, then
the generated time point must be before the time point which was passed in.
If the generated time point is ever passed the edge of the range in the
proper direction, then the edge of that range will be used instead. So, if
iterating forward, and the generated time point is past the interval's
end, then becomes frontend. If iterating backwards, and the
generated time point is before begin, then becomes
frontbegin. In either case, the range would then be empty.
Also note that while normally the begin of an interval is included in
it and its end is excluded from it, if dir == , then
Direction.bwdbegin is treated as excluded and end is treated as included. This
allows for the same behavior in both directions. This works because none of
.Interval, Interval's functions which care about whether begin or end is
included or excluded are ever called by . IntervalRange
returns a normal intervalinterval, regardless of whether dir ==
or if Direction.fwddir == , so any Direction.bwd.Interval, Interval functions which are
called on it which care about whether begin or end are included or
excluded will treat begin as included and end as excluded.
Properties
| Name | Type | Description |
|---|---|---|
direction
[get]
|
Direction |
The that this range iterates in.
|
empty
[get]
|
bool |
Whether this is empty.
|
front
[get]
|
TP |
The first time point in the range. |
func
[get]
|
TP delegate(in TP) |
The function used to generate the next time point in the range. |
interval
[get]
|
Interval!TP |
The interval that this currently covers.
|
save
[get]
|
IntervalRange |
Returns a copy of this.
|
Methods
| Name | Description |
|---|---|
opAssign
|
|
popFront
|
Pops from the range, using to generate the next
time point in the range. If the generated time point is beyond the edge
of the range, then is set to that edge, and the range is then
empty. So, if iterating forwards, and the generated time point is
greater than the interval's end, then is set to
end. If iterating backwards, and the generated time point is less
than the interval's begin, then is set to begin.
|
Authors
Jonathan M Davis and Kato Shoichi