View source code
Display the source code in std/datetime.d from which this page was generated on
github.
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.
Page wiki
View or edit the community-maintained wiki page associated with this page.
Template std.datetime.Interval.expand
Expands the interval forwards and/or backwards in time. Effectively,
it does
and/or begin
-= duration
. Whether
it expands forwards and/or backwards in time is determined by
dir.
end
+= duration
Arguments
template expand(D);
Functions
Function name | Description |
---|---|
expand |
Parameters
Name | Description |
---|---|
duration | The duration to expand the interval by. |
dir | The direction in time to expand the interval. |
Throws
DateTimeException
this interval is empty
or if the resulting
interval would be invalid.
Examples
auto interval1 = Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)); auto interval2 = Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)); interval1.expand(2); assert(interval1 == Interval!Date(Date(1994, 1, 2), Date(2014, 3, 1))); interval2.expand(-2); assert(interval2 == Interval!Date(Date(1998, 1, 2), Date(2010, 3, 1)));
Authors
Jonathan M Davis and Kato Shoichi