ruby-changes:19378
From: tenderlove <ko1@a...>
Date: Wed, 4 May 2011 08:06:27 +0900 (JST)
Subject: [ruby-changes:19378] Ruby:r31418 (trunk): * ext/psych/lib/psych/visitors/yaml_tree.rb: fix time dumping so that
tenderlove 2011-05-04 08:06:19 +0900 (Wed, 04 May 2011) New Revision: 31418 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=31418 Log: * ext/psych/lib/psych/visitors/yaml_tree.rb: fix time dumping so that Syck can load UTC times that Psych dumps. Modified files: trunk/ChangeLog trunk/ext/psych/lib/psych/visitors/yaml_tree.rb trunk/test/psych/json/test_stream.rb trunk/test/psych/test_json_tree.rb trunk/test/psych/test_yaml.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 31417) +++ ChangeLog (revision 31418) @@ -1,3 +1,8 @@ +Wed May 4 08:04:59 2011 Aaron Patterson <aaron@t...> + + * ext/psych/lib/psych/visitors/yaml_tree.rb: fix time dumping so that + Syck can load UTC times that Psych dumps. + Wed May 4 07:33:00 2011 KOSAKI Motohiro <kosaki.motohiro@g...> * thread.c (rb_fd_copy): fix wrong argument.This issue was pointed Index: ext/psych/lib/psych/visitors/yaml_tree.rb =================================================================== --- ext/psych/lib/psych/visitors/yaml_tree.rb (revision 31417) +++ ext/psych/lib/psych/visitors/yaml_tree.rb (revision 31418) @@ -297,7 +297,7 @@ private def format_time time if time.utc? - time.strftime("%Y-%m-%d %H:%M:%S.%9NZ") + time.strftime("%Y-%m-%d %H:%M:%S.%9N Z") else time.strftime("%Y-%m-%d %H:%M:%S.%9N %:z") end Index: test/psych/json/test_stream.rb =================================================================== --- test/psych/json/test_stream.rb (revision 31417) +++ test/psych/json/test_stream.rb (revision 31418) @@ -95,7 +95,7 @@ time = Time.utc(2010, 10, 10) @stream.push({'a' => time }) json = @io.string - assert_match "{\"a\": \"2010-10-10 00:00:00.000000000Z\"}\n", json + assert_match "{\"a\": \"2010-10-10 00:00:00.000000000 Z\"}\n", json end def test_datetime Index: test/psych/test_json_tree.rb =================================================================== --- test/psych/test_json_tree.rb (revision 31417) +++ test/psych/test_json_tree.rb (revision 31418) @@ -53,7 +53,7 @@ def test_time time = Time.utc(2010, 10, 10) - assert_equal "{\"a\": \"2010-10-10 00:00:00.000000000Z\"}\n", + assert_equal "{\"a\": \"2010-10-10 00:00:00.000000000 Z\"}\n", Psych.to_json({'a' => time }) end Index: test/psych/test_yaml.rb =================================================================== --- test/psych/test_yaml.rb (revision 31417) +++ test/psych/test_yaml.rb (revision 31418) @@ -14,6 +14,12 @@ Psych.domain_types.clear end + def test_syck_compat + time = Time.utc(2010, 10, 10) + yaml = Psych.dump time + assert_match "2010-10-10 00:00:00.000000000 Z", yaml + end + # [ruby-core:34969] def test_regexp_with_n assert_cycle(Regexp.new('',0,'n')) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/