View source code
Display the source code in std/datetime.d from which this page was generated on
github.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Page wiki
View or edit the community-maintained wiki page associated with this page.
std.datetime.valid
- multiple declarations
- Function valid
- Function valid
Function 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).
Prototype
bool valid(string units)( int value ) pure nothrow @safe if (units == "months" || units == "hours" || units == "minutes" || units == "seconds");
Parameters
Name | Description |
---|---|
units | The units of time to validate. |
value | The number to validate. |
Example
assert(valid!"hours"(12)); assert(!valid!"hours"(32)); assert(valid!"months"(12)); assert(!valid!"months"(13));
Function valid
Returns whether the given day
is valid
for the given year
and month
.
Prototype
bool valid(string units)( int year, int month, int day ) pure nothrow @safe if (units == "days");
Parameters
Name | Description |
---|---|
units | The units of time to validate. |
year | The year of the day to validate. |
month | The month of the day to validate. |
day | The day to validate. |
Authors
Jonathan M Davis and Kato Shoichi