Bug #13101

Date#rfc2822 and Time#rfc2822 don't return the same format

Added by iain_nl (Iain Hecker) almost 4 years ago. Updated over 1 year ago.

Target version:
ruby -v:
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]


Using the rfc2822 method on various date/time classes returns a slightly different result each time:     # => "Wed, 04 Jan 2017 10:21:06 -0500"   # => "Wed, 4 Jan 2017 00:00:00 +0000" # => "Wed, 04 Jan 2017 15:21:28 -0000" # => "Wed, 4 Jan 2017 10:21:39 -0500"

I don't think rfc2822 specifies if the day needs to have a prefix. The difference between the time zone +0000 and -0000 is technically correct.

Updated by mozamimy (Moza USANE) over 3 years ago

I created a patch to solve this issue in
I want committers to merge this patch if it's acceptable :)

Updated by mozamimy (Moza USANE) over 3 years ago

RFC 2822 says the date part should be 1 or 2 digits.
So current behavior doesn't violate the specification but I think it is more natural to adjust format.


Updated by akr (Akira Tanaka) over 3 years ago

  • Status changed from Open to Feedback

I think there is no problem with time.rb.

I don't want to change the day format in time.rb
because the current behavior is valid according to RFC 2822 and
needless behavior change can cause incompatibility.

Also, time.rb's -0000 is intentional.
It distinguishes UTC from the standard time of UK.


Updated by jeremyevans0 (Jeremy Evans) over 1 year ago

  • Status changed from Feedback to Closed

Also available in: Atom PDF