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:
parent
77e941269f
commit
ae28f1b6b3
9 changed files with 1085 additions and 801 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue