everyDayOfWeek

Range-generating function.

Returns a delegate which returns the next time point with the given DayOfWeek in a range.

Using this delegate allows iteration over successive time points which are all the same day of the week. e.g. passing DayOfWeek.mon to everyDayOfWeek would result in a delegate which could be used to iterate over all of the Mondays in a range.

nothrow
TP delegate
(
scope const TP
)
everyDayOfWeek
if (
(
dir == Direction.fwd ||
)
&&
__traits(hasMember, TP, "dayOfWeek")
&&
!__traits(isStaticFunction, TP.dayOfWeek)
&&
is(typeof(TP.dayOfWeek) == DayOfWeek)
)

Parameters

dir

The direction to iterate in. If passing the return value to fwdRange, use Direction.fwd. If passing it to bwdRange, use Direction.bwd.

dayOfWeek DayOfWeek

The week that each time point in the range will be.

Examples

import std.datetime.date : Date, DayOfWeek;

auto interval = Interval!Date(Date(2010, 9, 2), Date(2010, 9, 27));
auto func = everyDayOfWeek!Date(DayOfWeek.mon);
auto range = interval.fwdRange(func);

// A Thursday. Using PopFirst.yes would have made this Date(2010, 9, 6).
assert(range.front == Date(2010, 9, 2));

range.popFront();
assert(range.front == Date(2010, 9, 6));

range.popFront();
assert(range.front == Date(2010, 9, 13));

range.popFront();
assert(range.front == Date(2010, 9, 20));

range.popFront();
assert(range.empty);

Meta