From d47073de04f706c9d044b0fad694e5936dabc207 Mon Sep 17 00:00:00 2001 From: tenderlove Date: Tue, 3 May 2011 23:06:19 +0000 Subject: * ext/psych/lib/psych/visitors/yaml_tree.rb: fix time dumping so that Syck can load UTC times that Psych dumps. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31418 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ ext/psych/lib/psych/visitors/yaml_tree.rb | 2 +- test/psych/json/test_stream.rb | 2 +- test/psych/test_json_tree.rb | 2 +- test/psych/test_yaml.rb | 6 ++++++ 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index c9a0fc80ce..e23b394945 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed May 4 08:04:59 2011 Aaron Patterson + + * 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 * thread.c (rb_fd_copy): fix wrong argument.This issue was pointed diff --git a/ext/psych/lib/psych/visitors/yaml_tree.rb b/ext/psych/lib/psych/visitors/yaml_tree.rb index 84ebc90a7e..6f90377ec8 100644 --- a/ext/psych/lib/psych/visitors/yaml_tree.rb +++ b/ext/psych/lib/psych/visitors/yaml_tree.rb @@ -297,7 +297,7 @@ module Psych 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 diff --git a/test/psych/json/test_stream.rb b/test/psych/json/test_stream.rb index 0af64c1885..4690ad2f1e 100644 --- a/test/psych/json/test_stream.rb +++ b/test/psych/json/test_stream.rb @@ -95,7 +95,7 @@ module Psych 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 diff --git a/test/psych/test_json_tree.rb b/test/psych/test_json_tree.rb index fefa1f5da0..eed8cf36c4 100644 --- a/test/psych/test_json_tree.rb +++ b/test/psych/test_json_tree.rb @@ -53,7 +53,7 @@ module Psych 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 diff --git a/test/psych/test_yaml.rb b/test/psych/test_yaml.rb index 5c2f6dc3bf..41bb377143 100644 --- a/test/psych/test_yaml.rb +++ b/test/psych/test_yaml.rb @@ -14,6 +14,12 @@ class Psych_Unit_Tests < Psych::TestCase 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')) -- cgit v1.2.3