The OpenD Programming Language

YearQuarter.add

  1. YearQuarter add(long quarters)
    struct YearQuarter
    deprecated @safe pure nothrow @nogc ref
    add
    (
    string units : "quarters"
    )
    ()
  2. YearQuarter add(long years)

Examples

auto yq0 = YearQuarter(2020, Quarter.q1);

yq0.add!"quarters"(1);
assert(yq0.year == 2020);
assert(yq0.quarter == Quarter.q2);

auto yq1 = yq0.add!"quarters"(1);
assert(yq1.year == 2020);
assert(yq1.quarter == Quarter.q3);

// also changes yq0
assert(yq0.year == 2020);
assert(yq0.quarter == Quarter.q3);

yq1.add!"quarters"(2);
assert(yq1.year == 2021);
assert(yq1.quarter == Quarter.q1);

yq1.add!"quarters"(-5);
assert(yq1.year == 2019);
assert(yq1.quarter == Quarter.q4);

Meta