1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/syck/gram.c: added grammar for certain empty sequence entries.

* ext/syck/handler.c, ext/syck/syck.c, ext/syck/syck.h: track bad anchors.

* ext/syck/token.c: added pause token, tag possible circular references.

* lib/yaml/rubytypes.rb: parsing YMD time as Date instance.

* ext/syck/rubyext.c: ditto. DomainType, PrivateType, BadAlias classes.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3954 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
why 2003-06-17 16:55:54 +00:00
parent 77e941269f
commit ae28f1b6b3
9 changed files with 1085 additions and 801 deletions

View file

@ -451,17 +451,9 @@ class Time
end
end
YAML.add_builtin_type( 'time' ) { |type, val|
if val =~ /\A(\d{4})\-(\d{1,2})\-(\d{1,2})[Tt](\d{2})\:(\d{2})\:(\d{2})(\.\d{1,2})?(Z|[-+][0-9][0-9](?:\:[0-9][0-9])?)\Z/
YAML.mktime( *$~.to_a[1,8] )
elsif val =~ /\A(\d{4})\-(\d{1,2})\-(\d{1,2})[ \t]+(\d{2})\:(\d{2})\:(\d{2})(\.\d+)?[ \t]+(Z|[-+][0-9][0-9](?:\:[0-9][0-9])?)\Z/
YAML.mktime( *$~.to_a[1,8] )
elsif val =~ /\A(\d{4})\-(\d{1,2})\-(\d{1,2})[ \t]+(\d{2})\:(\d{2})\:(\d{2})(\.\d{1,2})?\Z/
YAML.mktime( *$~.to_a[1,7] )
elsif val =~ /\A(\d{4})\-(\d{1,2})\-(\d{1,2})\Z/
YAML.add_builtin_type( 'time#ymd' ) { |type, val|
if val =~ /\A(\d{4})\-(\d{1,2})\-(\d{1,2})\Z/
Date.new($1.to_i, $2.to_i, $3.to_i)
elsif type == :Implicit
:InvalidType
else
raise YAML::TypeError, "Invalid !time string: " + val.inspect
end