enforceValid

  1. void enforceValid(int value, string file, size_t line)
    @safe pure
    void
    enforceValid
    (
    string units
    )
    (
    int value
    ,
    string file = __FILE__
    ,
    size_t line = __LINE__
    )
    if (
    units == "months" ||
    units == "hours"
    ||
    units == "minutes"
    ||
    units == "seconds"
    )
  2. void enforceValid(int year, Month month, int day, string file, size_t line)

Parameters

units

The units of time to validate.

value int

The number to validate.

file string

The file that the DateTimeException will list if thrown.

line size_t

The line number that the DateTimeException will list if thrown.

Throws

DateTimeException if valid!units(value) is false.

Examples

import std.exception : assertThrown, assertNotThrown;

assertNotThrown(enforceValid!"months"(10));
assertNotThrown(enforceValid!"seconds"(40));

assertThrown!DateTimeException(enforceValid!"months"(0));
assertThrown!DateTimeException(enforceValid!"hours"(24));
assertThrown!DateTimeException(enforceValid!"minutes"(60));
assertThrown!DateTimeException(enforceValid!"seconds"(60));

Meta