View source code
Display the source code in std/datetime/interval.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Function std.datetime.interval.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
to
everyDayOfWeek
would result in a delegate which could be used to
iterate over all of the Mondays in a range.
Parameters
Name | Description |
---|---|
dir | The direction to iterate in. If passing the return value to
fwdRange , use Direction . If passing it to
bwdRange , use Direction . |
dayOfWeek | The week that each time point in the range will be. |
Example
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).
writeln(range .front); // Date(2010, 9, 2)
range .popFront();
writeln(range .front); // Date(2010, 9, 6)
range .popFront();
writeln(range .front); // Date(2010, 9, 13)
range .popFront();
writeln(range .front); // Date(2010, 9, 20)
range .popFront();
assert(range .empty);
Authors
License
Copyright © 1999-2018 by the D Language Foundation | Page generated by ddox.