Skip to content

Commit

Permalink
Returning early from parse_attribute_value for existing Date/DateTime…
Browse files Browse the repository at this point in the history
… fields
  • Loading branch information
andyjeffries committed Jul 18, 2016
1 parent 38810e3 commit e56f5ee
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/flexirest/attribute_parsing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ module AttributeParsing
private

def parse_attribute_value(v)
return v if v.is_a?(Date) || v.is_a?(DateTime)

if v.to_s[(/\A(((19|20)\d\d[- \/.](0[1-9]|1[012]|[1-9])[- \/.](0[1-9]|[12][0-9]|3[01]|[1-9]))|((0[1-9]|1[012]|[1-9])[- \/.](0[1-9]|[12][0-9]|3[01]|[1-9])[- \/.](19|20)\d\d))\Z/)]
Date.parse(v)
elsif v.to_s[/\A([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?))\Z/]
Expand Down

0 comments on commit e56f5ee

Please sign in to comment.