The OpenD Programming Language

TimeOfDay.opBinary

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

The legal types of arithmetic for TimeOfDay using this operator are

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

Parameters

duration Duration

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

Examples

import core.time : hours, minutes, seconds;

assert(TimeOfDay(12, 12, 12) + seconds(1) == TimeOfDay(12, 12, 13));
assert(TimeOfDay(12, 12, 12) + minutes(1) == TimeOfDay(12, 13, 12));
assert(TimeOfDay(12, 12, 12) + hours(1) == TimeOfDay(13, 12, 12));
assert(TimeOfDay(23, 59, 59) + seconds(1) == TimeOfDay(0, 0, 0));

assert(TimeOfDay(12, 12, 12) - seconds(1) == TimeOfDay(12, 12, 11));
assert(TimeOfDay(12, 12, 12) - minutes(1) == TimeOfDay(12, 11, 12));
assert(TimeOfDay(12, 12, 12) - hours(1) == TimeOfDay(11, 12, 12));
assert(TimeOfDay(0, 0, 0) - seconds(1) == TimeOfDay(23, 59, 59));

Meta