Skip to content

Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →

class method

Date._strptime

(::String str, ?::String format) -> ::Hash[::Symbol, ::Integer]
Date._strptime(string, format = '%F') → hash

Returns a hash of values parsed from string according to the given format:

Example
Date._strptime('2001-02-03', '%Y-%m-%d') # => {:year=>2001, :mon=>2, :mday=>3}

For other formats, see Formats for Dates and Times. (Unlike Date.strftime, does not support flags and width.)

See also strptime(3).

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

See also .rfc822 .strptime ._rfc822 .today also in 4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0