Date.opBinaryRight

Gives the result of adding or subtracting a core.time.Duration from this Date.

The legal types of arithmetic for Date using this operator are

Date+Duration-->Date
Date-Duration-->Date
Duration+Date-->Date
struct Date
const @safe pure nothrow @nogc
opBinaryRight
(
string op
)
(
Duration duration
)
if (
op == "+"
)

Parameters

duration Duration

The core.time.Duration to add to or subtract from this Date.

Examples

import core.time : days;

assert(Date(2015, 12, 31) + days(1) == Date(2016, 1, 1));
assert(Date(2004, 2, 26) + days(4) == Date(2004, 3, 1));

assert(Date(2016, 1, 1) - days(1) == Date(2015, 12, 31));
assert(Date(2004, 3, 1) - days(4) == Date(2004, 2, 26));

assert(Date(2004, 2, 26) + days(4) == days(4) + Date(2004, 2, 26));

Meta