Skip to content

Commit

Permalink
Fix JSON decoder date-converter regexp [#1662 state:resolved] [Jonath…
Browse files Browse the repository at this point in the history
…an del Strother]
  • Loading branch information
lifo committed Jan 7, 2009
1 parent 2f92313 commit 17da45b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/json/decoding.rb
Expand Up @@ -16,7 +16,7 @@ def decode(json)

protected
# matches YAML-formatted dates
DATE_REGEX = /^\d{4}-\d{2}-\d{2}|\d{4}-\d{1,2}-\d{1,2}[ \t]+\d{1,2}:\d{2}:\d{2}(\.[0-9]*)?(([ \t]*)Z|[-+]\d{2}?(:\d{2})?)?$/
DATE_REGEX = /^(?:\d{4}-\d{2}-\d{2}|\d{4}-\d{1,2}-\d{1,2}[ \t]+\d{1,2}:\d{2}:\d{2}(\.[0-9]*)?(([ \t]*)Z|[-+]\d{2}?(:\d{2})?)?)$/

# Ensure that ":" and "," are always followed by a space
def convert_json_to_yaml(json) #:nodoc:
Expand Down
3 changes: 2 additions & 1 deletion activesupport/test/json/decoding_test.rb
Expand Up @@ -15,7 +15,8 @@ class TestJSONDecoding < Test::Unit::TestCase
# no time zone
%({a: "2007-01-01 01:12:34"}) => {'a' => "2007-01-01 01:12:34"},
# needs to be *exact*
%({a: " 2007-01-01 01:12:34 Z "}) => {'a' => " 2007-01-01 01:12:34 Z "},
%({a: " 2007-01-01 01:12:34 Z "}) => {'a' => " 2007-01-01 01:12:34 Z "},
%({a: "2007-01-01 : it's your birthday"}) => {'a' => "2007-01-01 : it's your birthday"},
%([]) => [],
%({}) => {},
%(1) => 1,
Expand Down

0 comments on commit 17da45b

Please sign in to comment.