fromSimpleString

Creates a Date from a string with the format YYYY-Mon-DD.

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

Parameters

str const(C)[]

A string formatted in the way that .date.toSimpleString formats 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.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));

Meta