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.PosInfInterval.expand
- multiple declarations
Function PosInfInterval.expand
Expands the interval forwards and/or backwards in time. Effectively,
it subtracts the given number of months/years from begin
.
void expand(T)
(
T years,
T months = 0,
AllowDayOverflow allowOverflow = AllowDayOverflow .yes
)
if (isIntegral!T);
Parameters
Name | Description |
---|---|
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 begin , causing its month to increment. |
Throws
DateTimeException
if this interval is
empty or if the resulting interval would be invalid.
Example
auto interval1 = PosInfInterval!Date(Date(1996, 1, 2));
auto interval2 = PosInfInterval!Date(Date(1996, 1, 2));
interval1 .expand(2);
assert(interval1 == PosInfInterval!Date(Date(1994, 1, 2)));
interval2 .expand(-2);
assert(interval2 == PosInfInterval!Date(Date(1998, 1, 2)));
Function PosInfInterval.expand
Expands the interval backwards in time. Effectively, it does
begin -= duration
.
void expand(D)
(
D duration
) pure nothrow
if (__traits(compiles, begin + duration));
Parameters
Name | Description |
---|---|
duration | The duration to expand the interval by. |
Example
auto interval1 = PosInfInterval!Date(Date(1996, 1, 2));
auto interval2 = PosInfInterval!Date(Date(1996, 1, 2));
interval1 .expand(dur!"days"(2));
assert(interval1 == PosInfInterval!Date(Date(1995, 12, 31)));
interval2 .expand(dur!"days"(-2));
assert(interval2 == PosInfInterval!Date(Date(1996, 1, 4)));
Authors
License
Copyright © 1999-2018 by the D Language Foundation | Page generated by ddox.