End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Time#rfc2822
rfc2822
lib/time.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.0.5/lib/time.rb, line 666
def rfc2822
sprintf('%s, %02d %s %0*d %02d:%02d:%02d ',
RFC2822_DAY_NAME[wday],
day, RFC2822_MONTH_NAME[mon-1], year < 0 ? 5 : 4, year,
hour, min, sec) <<
if utc?
'-0000'
else
off = utc_offset
sign = off < 0 ? '-' : '+'
sprintf('%s%02d%02d', sign, *(off.abs / 60).divmod(60))
end
end
Returns a string which represents the time as date-time defined by RFC 2822:
day-of-week, DD month-name CCYY hh:mm:ss zone
where zone is [+-]hhmm.
If self is a UTC time, -0000 is used as zone.
Example
require 'time' t = Time.now t.rfc2822 # => "Wed, 05 Oct 2011 22:26:12 -0400"
You must require ‘time’ to use this method.