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)
  2. Date fromString(const(C)[] str)
    static @safe pure
    fromString
    (
    C
    )
    (
    scope const(C)[] str
    )
    if (
    isSomeChar!C
    )

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.

Return Value

Type: Date

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