valid

Returns whether the given value is valid for the given unit type when in a time point. Naturally, a duration is not held to a particular range, but the values in a time point are (e.g. a month must be in the range of 1 - 12 inclusive).

  1. bool valid(int value)
    @safe pure nothrow @nogc
    bool
    valid
    (
    string units
    )
    (
    int value
    )
    if (
    units == "months" ||
    units == "hours"
    ||
    units == "minutes"
    ||
    units == "seconds"
    )
  2. bool valid(int year, int month, int day)

Parameters

units

The units of time to validate.

value int

The number to validate.

Examples

assert(valid!"hours"(12));
assert(!valid!"hours"(32));
assert(valid!"months"(12));
assert(!valid!"months"(13));

Meta