Skip to content

Require offset when parsing RFC3339#72

Open
bdewater-thatch wants to merge 1 commit into
ruby:masterfrom
bdewater-thatch:fix-rfc3339-require-offset
Open

Require offset when parsing RFC3339#72
bdewater-thatch wants to merge 1 commit into
ruby:masterfrom
bdewater-thatch:fix-rfc3339-require-offset

Conversation

@bdewater-thatch

@bdewater-thatch bdewater-thatch commented Jul 22, 2026

Copy link
Copy Markdown

#59 introduced Time.rfc3339. Parsing RFC3339 requires a Z designator or explicit numeric offset. This PR rejects offset-less timestamps instead of passing them to Time.new, which interprets them in local time.

The Rails unit tests for same method surfaced the difference in implementations: rails/rails#58172

DateTime also correctly raises:

irb(main):004> DateTime.rfc3339("2026-07-22T12:34:56")
(irb):4:in 'DateTime.rfc3339': invalid date (Date::Error)

RFC3339 requires a Z designator or explicit numeric offset. Reject offset-less timestamps instead of passing them to Time.new, which interprets them in local time.
@jeremyevans

Copy link
Copy Markdown
Contributor

Thank you for the report. I'm checking with one of the Rails maintainers in #73 to see if this PR will pass the Rails specs. If so, I'll merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants