The OpenD Programming Language

Date.fromSimpleString

Creates a Date from a string with the format YYYY-Mon-DD. Whitespace is stripped from the given string.

struct Date
static @safe pure
fromSimpleString
(
S
)
(
scope const S simpleString
)

Parameters

simpleString S

A string formatted in the way that toSimpleString formats dates.

Throws

std.datetime.date.DateTimeException if the given string is not in the correct format or if the resulting Date would not be valid.

Examples

assert(Date.fromSimpleString("2010-Jul-04") == Date(2010, 7, 4));
assert(Date.fromSimpleString("1998-Dec-25") == Date(1998, 12, 25));
assert(Date.fromSimpleString("0000-Jan-05") == Date(0, 1, 5));
assert(Date.fromSimpleString("-0004-Jan-05") == Date(-4, 1, 5));
assert(Date.fromSimpleString(" 2010-Jul-04 ") == Date(2010, 7, 4));

Meta