Skip to content
class method

Date._parse

(::String str, ?::boolish complete) -> ::Hash[::Symbol, ::Integer]
Date._parse(string, comp = true, limit: 128) → hash

Note: This method recognizes many forms in string, but it is not a validator. For formats, see “Specialized Format Strings” in Formats for Dates and Times

If string does not specify a valid date, the result is unpredictable; consider using Date._strptime instead.

Returns a hash of values parsed from string:

Example
Date._parse('2001-02-03') # => {:year=>2001, :mon=>2, :mday=>3}

If comp is true and the given year is in the range (0..99), the current century is supplied; otherwise, the year is taken as given:

Example
Date._parse('01-02-03', true)  # => {:year=>2001, :mon=>2, :mday=>3}
Date._parse('01-02-03', false) # => {:year=>1, :mon=>2, :mday=>3}

See argument limit.

Related: Date.parse(returns a Date object).

See also .ordinal .parse .new ._rfc2822 also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0