diff options
author | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-07-05 23:12:44 +0000 |
---|---|---|
committer | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-07-05 23:12:44 +0000 |
commit | c27e0ebab690d2a6c709a5a2c83af2d7a4968492 (patch) | |
tree | 296e757a7198b972cef76f911074e501c67aa844 | |
parent | f32ae44629199af0462be3ac15359a9ad7c56999 (diff) | |
download | ruby-c27e0ebab690d2a6c709a5a2c83af2d7a4968492.tar.gz |
* 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
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ext/psych/lib/psych/visitors/yaml_tree.rb | 4 | ||||
-rw-r--r-- | test/psych/visitors/test_to_ruby.rb | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/ext/psych/lib/psych/visitors/yaml_tree.rb b/ext/psych/lib/psych/visitors/yaml_tree.rb index ebafffd7c9..4df7b4d5db 100644 --- a/ext/psych/lib/psych/visitors/yaml_tree.rb +++ b/ext/psych/lib/psych/visitors/yaml_tree.rb @@ -271,9 +271,9 @@ module Psych 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 diff --git a/test/psych/visitors/test_to_ruby.rb b/test/psych/visitors/test_to_ruby.rb index eb2841d9d0..1a4d3194f3 100644 --- a/test/psych/visitors/test_to_ruby.rb +++ b/test/psych/visitors/test_to_ruby.rb @@ -113,7 +113,7 @@ description: 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 @@ description: 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 @@ description: 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 |