Function std.datetime.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
to
Month.dec
to create the delegate.
everyMonth
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,
is always used when
calculating the next time point.
AllowDayOverflow.no
Prototype
TP delegate(in TP) everyMonth(TP, std.datetime.Direction dir)( int month ) if (isTimePoint!TP && (dir == Direction.fwd || dir == Direction.bwd) && __traits(hasMember, TP, "month") && !__traits(isStaticFunction, TP.month) && is(typeof(TP.month) == Month));
Parameters
Name | Description |
---|---|
dir | The direction to iterate in. If passing the return value to
fwdRange , use . If passing it to
bwdRange , use . |
month | The month that each time point in the range will be in. |
Example
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);
Authors
Jonathan M Davis and Kato Shoichi