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.

std.datetime.interval.NegInfInterval.expand - multiple declarations

Function NegInfInterval.expand

Expands the interval forwards and/or backwards in time. Effectively, it adds the given number of months/years to end.

void expand(T) (
  T years,
  T months = 0,
  AllowDayOverflow allowOverflow = AllowDayOverflow.yes
)
if (isIntegral!T);

Parameters

NameDescription
years The number of years to expand the interval by.
months The number of months to expand the interval by.
allowOverflow Whether the days should be allowed to overflow on end, causing their month to increment.

Throws

DateTimeException if empty is true or if the resulting interval would be invalid.

Example

auto interval1 = NegInfInterval!Date(Date(2012, 3, 1));
auto interval2 = NegInfInterval!Date(Date(2012, 3, 1));

interval1.expand(2);
assert(interval1 == NegInfInterval!Date(Date(2014, 3, 1)));

interval2.expand(-2);
assert(interval2 == NegInfInterval!Date(Date(2010, 3, 1)));

Function NegInfInterval.expand

Expands the interval forwards in time. Effectively, it does end += duration.

void expand(D) (
  D duration
) pure nothrow
if (__traits(compiles, end + duration));

Parameters

NameDescription
duration The duration to expand the interval by.

Example

auto interval1 = NegInfInterval!Date(Date(2012, 3, 1));
auto interval2 = NegInfInterval!Date(Date(2012, 3, 1));

interval1.expand(dur!"days"(2));
assert(interval1 == NegInfInterval!Date(Date(2012, 3, 3)));

interval2.expand(dur!"days"(-2));
assert(interval2 == NegInfInterval!Date(Date(2012, 2, 28)));

Authors

Jonathan M Davis

License

Boost License 1.0.