Follow-up to #73 / #74: Time.rfc3339 on master (tested at 95ab5fa) accepts a numeric UTC offset written without the colon separator, which Section 5.6 of RFC 3339 does not allow.
Steps to reproduce
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "time", github: "ruby/time"
end
require "time"
require "date"
p Time.rfc3339("1999-12-31T19:00:00-0400")
p DateTime.rfc3339("1999-12-31T19:00:00-0400")
Expected behavior
Both calls raise. The ABNF in Section 5.6 (https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) reads:
time-numoffset = ("+" / "-") time-hour ":" time-minute
The colon between the hour and the minute of a numeric offset is not optional.
Actual behavior
1999-12-31 19:00:00 -0400
repro.rb:12:in 'DateTime.rfc3339': invalid date (Date::Error)
Time.rfc3339 accepts the string; DateTime.rfc3339 rejects it. The colon is optional in the offset group of the pattern:
References
Follow-up to #73 / #74:
Time.rfc3339on master (tested at 95ab5fa) accepts a numeric UTC offset written without the colon separator, which Section 5.6 of RFC 3339 does not allow.Steps to reproduce
Expected behavior
Both calls raise. The ABNF in Section 5.6 (https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) reads:
The colon between the hour and the minute of a numeric offset is not optional.
Actual behavior
Time.rfc3339accepts the string;DateTime.rfc3339rejects it. The colon is optional in the offset group of the pattern:time/lib/time.rb
Line 663 in 95ab5fa
References
DateTime.rfc3339parses viaDate._rfc3339: https://github.com/ruby/date/blob/3481cf7ce9149011f1a4eb2bfffc2a0b44c8bf07/ext/date/date_core.c#L8701-L8722Time.rfc3339is a thin wrapper around the sameDate._rfc3339, so Rails applications observe the same rejection: https://github.com/rails/rails/blob/fa8f0812160665bff083a089d2bb2fc1817ea03e/activesupport/lib/active_support/core_ext/time/calculations.rb#L69-L83