everyDuration

Range-generating function.

Returns a delegate which returns the next time point which is the given duration later.

Using this delegate allows iteration over successive time points which are apart by the given duration e.g. passing dur!"days"(3) to everyDuration would result in a delegate which could be used to iterate over a range of days which are each 3 days apart.

  1. TP delegate(return scope const TP) everyDuration(D duration)
    nothrow
    TP delegate
    (
    return scope const TP
    )
    everyDuration
    ()
    if (
    __traits(compiles, TP.init + duration)
    &&
    (
    dir == Direction.fwd ||
    )
    )
  2. TP delegate(scope const TP) everyDuration(int years, int months, AllowDayOverflow allowOverflow, D duration)

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.

duration D

The duration which separates each successive time point in the range.

Examples

import core.time : dur;
import std.datetime.date : Date;

auto interval = Interval!Date(Date(2010, 9, 2), Date(2010, 9, 27));
auto func = everyDuration!Date(dur!"days"(8));
auto range = interval.fwdRange(func);

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

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

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

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

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

Meta