The units of time to validate.
The year of the day to validate.
The month of the day to validate.
The day to validate.
The file that the DateTimeException will list if thrown.
The line number that the DateTimeException will list if thrown.
DateTimeException if valid!"days"(year, month, day) is false.
import std.exception : assertThrown, assertNotThrown; assertNotThrown(enforceValid!"days"(2000, Month.jan, 1)); // leap year assertNotThrown(enforceValid!"days"(2000, Month.feb, 29)); assertThrown!DateTimeException(enforceValid!"days"(2001, Month.feb, 29)); assertThrown!DateTimeException(enforceValid!"days"(2000, Month.jan, 32)); assertThrown!DateTimeException(enforceValid!"days"(2000, Month.apr, 31));
Because the validity of the day number depends on both on the year and month of which the day is occurring, take all three variables to validate the day.