everyMonth

Range-generating function.

Returns a delegate which returns the next time point with the given month which would be reached by adding months to the given time point.

So, using this delegate allows iteration over successive time points which are in the same month but different years. For example, iterate over each successive December 25th in an interval by starting with a date which had the 25th as its day and passed Month.dec to everyMonth to create the delegate.

Since it wouldn't really make sense to be iterating over a specific month and end up with some of the time points in the succeeding month or two years after the previous time point, AllowDayOverflow.no is always used when calculating the next time point.

TP delegate
(
scope const TP
)
everyMonth
(
int month
)
if (
(
dir == Direction.fwd ||
)
&&
__traits(hasMember, TP, "month")
&&
!__traits(isStaticFunction, TP.month)
&&
is(typeof(TP.month) == Month)
)

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.

month int

The month that each time point in the range will be in (January is 1).

Examples

import std.datetime.date : Date, Month;

auto interval = Interval!Date(Date(2000, 1, 30), Date(2004, 8, 5));
auto func = everyMonth!Date(Month.feb);
auto range = interval.fwdRange(func);

// Using PopFirst.yes would have made this Date(2010, 2, 29).
assert(range.front == Date(2000, 1, 30));

range.popFront();
assert(range.front == Date(2000, 2, 29));

range.popFront();
assert(range.front == Date(2001, 2, 28));

range.popFront();
assert(range.front == Date(2002, 2, 28));

range.popFront();
assert(range.front == Date(2003, 2, 28));

range.popFront();
assert(range.front == Date(2004, 2, 28));

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

Meta