Date.opBinary

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

The legal types of arithmetic for Date using this operator are

Date+Duration-->Date
Date-Duration-->Date
  1. Date opBinary(Duration duration)
    struct Date
    const @safe pure nothrow @nogc
    opBinary
    (
    string op
    )
    (
    Duration duration
    )
    if (
    op == "+" ||
    op == "-"
    )
  2. Duration opBinary(Date rhs)

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));

Meta