Skip to content

Handle case insensitive match for Time.{iso8601,xmlschema,rfc3339} - #75

Merged
jeremyevans merged 1 commit into
ruby:masterfrom
jeremyevans:fix-time-new-opt-case-insensitive
Aug 2, 2026
Merged

Handle case insensitive match for Time.{iso8601,xmlschema,rfc3339}#75
jeremyevans merged 1 commit into
ruby:masterfrom
jeremyevans:fix-time-new-opt-case-insensitive

Conversation

@jeremyevans

Copy link
Copy Markdown
Contributor

The T and Z in the regular expressions are case insensitive, but Time.new on Ruby 3.2+ does not support the lowercase versions. Arguably, lower case t and z shouldn't be allowed, but they were historically supported. Time.rfc3339 is a new method, so backwards compatibility is not technically necessary, but the ActiveSupport Time.rfc3339 method supports the lower case versions.

The optimization in b8c50d2 broke backwards compatibility for lower case t and z, since it started calling Time.new.

While I don't necessarily have a problem with breaking backwards compatibility in order to improve standards conformance (depending on the case), I think the decision should be deliberate and not accidental due to an optimization.

The fix is trivial, and doesn't cause an additional allocation, since strip already returns a fresh string.

The T and Z in the regular expressions are case insensitive, but
Time.new on Ruby 3.2+ does not support the lowercase versions.
Arguably, lower case t and z shouldn't be allowed, but they were
historically supported. Time.rfc3339 is a new method, so backwards
compatibility is not technically necessary, but the ActiveSupport
Time.rfc3339 method supports the lower case versions.

The optimization in b8c50d2 broke
backwards compatibility for lower case t and z, since it started
calling Time.new.

While I don't necessarily have a problem with breaking backwards
compatibility in order to improve standards conformance (depending
on the case), I think the decision should be deliberate and not
accidental due to an optimization.

The fix is trivial, and doesn't cause an additional allocation,
since strip already returns a fresh string.
@jeremyevans
jeremyevans merged commit 95ab5fa into ruby:master Aug 2, 2026
19 checks passed
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