Skip to content

Commit 228e954

Browse files
byrootsferik
andcommitted
Improve XmlMini date parsing
The TODO was suggesting to use a regexp, but `Date.strptime` is the fastest and most strict solution. Co-Authored-By: Erik Berlin <[email protected]>
1 parent 4c803a2 commit 228e954

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

activesupport/lib/active_support/xml_mini.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,10 @@ def content_type
6262
"yaml" => Proc.new { |yaml| yaml.to_yaml }
6363
} unless defined?(FORMATTING)
6464

65-
# TODO use regexp instead of Date.parse
6665
unless defined?(PARSING)
6766
PARSING = {
6867
"symbol" => Proc.new { |symbol| symbol.to_s.to_sym },
69-
"date" => Proc.new { |date| ::Date.parse(date) },
68+
"date" => Proc.new { |date| ::Date.strptime(date, "%Y-%m-%d") },
7069
"datetime" => Proc.new { |time| Time.xmlschema(time).utc rescue ::DateTime.parse(time).utc },
7170
"duration" => Proc.new { |duration| Duration.parse(duration) },
7271
"integer" => Proc.new { |integer| integer.to_i },

0 commit comments

Comments
 (0)