fromString

Creates a Date from a string with the format YYYY-MM-DD, YYYYMMDD, or YYYY-Mon-DD.

  1. bool fromString(const(C)[] str, Date value)
    static @safe pure nothrow @nogc
    bool
    fromString
    (
    C
    )
    (
    scope const(C)[] str
    ,)
  2. Date fromString(const(C)[] str)

Parameters

str const(C)[]

A string formatted in the way that .date.toISOExtString, .date.toISOString, and .date.toSimpleString format dates. The function is case sensetive.

value Date

(optional) result value.

Return Value

Type: bool

bool on success for two arguments overload, and the resulting date for single argument overdload.

Throws

DateTimeException if the given string is not in the correct format or if the resulting Date would not be valid. Two arguments overload is nothrow.

Examples

assert(Date.fromString("2010-07-04") == Date(2010, 7, 4));
assert(Date.fromString("20100704") == Date(2010, 7, 4));
assert(Date.fromString("2010-Jul-04") == Date(2010, 7, 4));

Meta