The OpenD Programming Language

SysTime.opBinary

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

The legal types of arithmetic for SysTime using this operator are

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

Parameters

duration Duration

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

Examples

import core.time : hours, seconds;
import std.datetime.date : DateTime;

assert(SysTime(DateTime(2015, 12, 31, 23, 59, 59)) + seconds(1) ==
       SysTime(DateTime(2016, 1, 1, 0, 0, 0)));

assert(SysTime(DateTime(2015, 12, 31, 23, 59, 59)) + hours(1) ==
       SysTime(DateTime(2016, 1, 1, 0, 59, 59)));

assert(SysTime(DateTime(2016, 1, 1, 0, 0, 0)) - seconds(1) ==
       SysTime(DateTime(2015, 12, 31, 23, 59, 59)));

assert(SysTime(DateTime(2016, 1, 1, 0, 59, 59)) - hours(1) ==
       SysTime(DateTime(2015, 12, 31, 23, 59, 59)));

Meta