Project

General

Profile

Bug #13101

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

Added by iain_nl (Iain Hecker) over 2 years ago. Updated about 2 years ago.

Status:
Feedback
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]
[ruby-core:78969]

Description

Using the rfc2822 method on various date/time classes returns a slightly different result each time:

Time.now.rfc2822     # => "Wed, 04 Jan 2017 10:21:06 -0500"
Date.today.rfc2822   # => "Wed, 4 Jan 2017 00:00:00 +0000"
Time.now.utc.rfc2822 # => "Wed, 04 Jan 2017 15:21:28 -0000"
DateTime.now.rfc2822 # => "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.

History

Updated by mozamimy (Moza USANE) about 2 years ago

I created a patch to solve this issue in https://github.com/ruby/ruby/pull/1566
I want committers to merge this patch if it's acceptable :)

Updated by mozamimy (Moza USANE) about 2 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.

ref. http://www.ietf.org/rfc/rfc2822.txt

Updated by akr (Akira Tanaka) about 2 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.

Also available in: Atom PDF