Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

class method

Date.rfc822

(::String str, ?::Integer start) -> ::Date
Date.rfc2822(string = 'Mon, 1 Jan -4712 00:00:00 +0000', start = Date::ITALY, limit: 128) → date

Returns a new Date object with values parsed from string, which should be a valid RFC 2822 date format:

Example
d = Date.new(2001, 2, 3)
s = d.rfc2822   # => "Sat, 3 Feb 2001 00:00:00 +0000"
Date.rfc2822(s) # => #<Date: 2001-02-03>

See:

Related: Date._rfc2822 (returns a hash).

See also #rfc822 ._rfc822 ._strptime .rfc3339 also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0