From ae28f1b6b3b22afb529f599385d1f2af258624e9 Mon Sep 17 00:00:00 2001 From: why Date: Tue, 17 Jun 2003 16:55:54 +0000 Subject: * 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 --- lib/yaml/rubytypes.rb | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/yaml/rubytypes.rb b/lib/yaml/rubytypes.rb index b2ac615849..2597c86a54 100644 --- a/lib/yaml/rubytypes.rb +++ b/lib/yaml/rubytypes.rb @@ -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 -- cgit v1.2.3