The OpenD Programming Language

Date.fromISOString

Creates a Date from a string with the format YYYYMMDD. Whitespace is stripped from the given string.

struct Date
static @safe pure
fromISOString
(
S
)
(
scope const S isoString
)

Parameters

isoString S

A string formatted in the ISO format for dates.

Throws

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

Examples

assert(Date.fromISOString("20100704") == Date(2010, 7, 4));
assert(Date.fromISOString("19981225") == Date(1998, 12, 25));
assert(Date.fromISOString("00000105") == Date(0, 1, 5));
assert(Date.fromISOString("-00040105") == Date(-4, 1, 5));
assert(Date.fromISOString(" 20100704 ") == Date(2010, 7, 4));

Meta