ruby-changes:16559
From: tenderlove <ko1@a...>
Date: Tue, 6 Jul 2010 08:12:52 +0900 (JST)
Subject: [ruby-changes:16559] Ruby:r28551 (trunk): * ext/psych/lib/psych/visitors/yaml_tree.rb (format_time): nanoseconds
tenderlove 2010-07-06 08:12:44 +0900 (Tue, 06 Jul 2010) New Revision: 28551 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=28551 Log: * ext/psych/lib/psych/visitors/yaml_tree.rb (format_time): nanoseconds require more digits when dumping. Thanks akr! [ruby-core:31047] * test/psych/visitors/test_to_ruby.rb: adjusting tests for nanoseconds Modified files: trunk/ext/psych/lib/psych/visitors/yaml_tree.rb trunk/test/psych/visitors/test_to_ruby.rb Index: ext/psych/lib/psych/visitors/yaml_tree.rb =================================================================== --- ext/psych/lib/psych/visitors/yaml_tree.rb (revision 28550) +++ ext/psych/lib/psych/visitors/yaml_tree.rb (revision 28551) @@ -271,9 +271,9 @@ def format_time time formatted = time.strftime("%Y-%m-%d %H:%M:%S") if time.utc? - formatted += ".%06dZ" % [time.nsec] + formatted += ".%09dZ" % [time.nsec] else - formatted += ".%06d %+.2d:%.2d" % [time.nsec, + formatted += ".%09d %+.2d:%.2d" % [time.nsec, time.gmt_offset / 3600, time.gmt_offset % 3600 / 60] end formatted Index: test/psych/visitors/test_to_ruby.rb =================================================================== --- test/psych/visitors/test_to_ruby.rb (revision 28550) +++ test/psych/visitors/test_to_ruby.rb (revision 28551) @@ -113,7 +113,7 @@ def test_time now = Time.now formatted = now.strftime("%Y-%m-%d %H:%M:%S") + - ".%06d %+.2d:00" % [now.nsec, now.gmt_offset / 3600] + ".%09d %+.2d:00" % [now.nsec, now.gmt_offset / 3600] assert_equal now, Nodes::Scalar.new(formatted).to_ruby end @@ -121,7 +121,7 @@ def test_time_utc now = Time.now.utc formatted = now.strftime("%Y-%m-%d %H:%M:%S") + - ".%06dZ" % [now.nsec] + ".%09dZ" % [now.nsec] assert_equal now, Nodes::Scalar.new(formatted).to_ruby end @@ -129,7 +129,7 @@ def test_time_utc_no_z now = Time.now.utc formatted = now.strftime("%Y-%m-%d %H:%M:%S") + - ".%06d" % [now.nsec] + ".%09d" % [now.nsec] assert_equal now, Nodes::Scalar.new(formatted).to_ruby end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/