summaryrefslogtreecommitdiff
path: root/test/visitors/test_to_ruby.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/visitors/test_to_ruby.rb')
-rw-r--r--test/visitors/test_to_ruby.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/visitors/test_to_ruby.rb b/test/visitors/test_to_ruby.rb
index c60a9b9..41eae48 100644
--- a/test/visitors/test_to_ruby.rb
+++ b/test/visitors/test_to_ruby.rb
@@ -11,6 +11,30 @@ module Psych
@visitor = ToRuby.new
end
+ def test_time
+ now = Time.now
+ formatted = now.strftime("%Y-%m-%d %H:%M:%S") +
+ ".%06d %d:00" % [now.usec, now.gmt_offset / 3600]
+
+ assert_equal now, Nodes::Scalar.new(formatted).to_ruby
+ end
+
+ def test_time_utc
+ now = Time.now.utc
+ formatted = now.strftime("%Y-%m-%d %H:%M:%S") +
+ ".%06dZ" % [now.usec]
+
+ assert_equal now, Nodes::Scalar.new(formatted).to_ruby
+ end
+
+ def test_time_utc_no_z
+ now = Time.now.utc
+ formatted = now.strftime("%Y-%m-%d %H:%M:%S") +
+ ".%06d" % [now.usec]
+
+ assert_equal now, Nodes::Scalar.new(formatted).to_ruby
+ end
+
def test_date
d = '1980-12-16'
actual = Date.strptime(d, '%Y-%m-%d')