Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix regexp for matching TIME.
fixes #171
  • Loading branch information
tenderlove committed Nov 26, 2013
1 parent 1003a03 commit 6066fcc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.rdoc
@@ -1,3 +1,10 @@
Wed Nov 27 04:46:55 2013 Aaron Patterson <aaron@tenderlovemaking.com>

* ext/psych/lib/psych/scalar_scanner.rb: fix regexp for matching TIME
strings.
* test/psych/test_date_time.rb: test for change.
Fixes: https://github.com/tenderlove/psych/issues/171

Wed Nov 6 04:14:25 2013 Aaron Patterson <aaron@tenderlovemaking.com>

* ext/psych/lib/psych/visitors/to_ruby.rb: process merge keys before
Expand Down
2 changes: 1 addition & 1 deletion lib/psych/scalar_scanner.rb
Expand Up @@ -5,7 +5,7 @@ module Psych
# Scan scalars for built in types
class ScalarScanner
# Taken from http://yaml.org/type/timestamp.html
TIME = /^\d{4}-\d{1,2}-\d{1,2}([Tt]|\s+)\d{1,2}:\d\d:\d\d(\.\d*)?(\s*Z|[-+]\d{1,2}(:\d\d)?)?/
TIME = /^\d{4}-\d{1,2}-\d{1,2}(?:[Tt]|\s+)\d{1,2}:\d\d:\d\d(?:\.\d*)?(?:\s*(?:Z|[-+]\d{1,2}:?(?:\d\d)?))?$/

# Taken from http://yaml.org/type/float.html
FLOAT = /^(?:[-+]?([0-9][0-9_,]*)?\.[0-9]*([eE][-+][0-9]+)?(?# base 10)
Expand Down
4 changes: 4 additions & 0 deletions test/psych/test_date_time.rb
Expand Up @@ -3,6 +3,10 @@

module Psych
class TestDateTime < TestCase
def test_invalid_date
assert_cycle "2013-10-31T10:40:07-000000000000033"
end

def test_string_tag
dt = DateTime.now
yaml = Psych.dump dt
Expand Down

0 comments on commit 6066fcc

Please sign in to comment.