summaryrefslogtreecommitdiff
path: root/test/visitors
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2009-10-06 19:34:57 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2009-10-06 19:34:57 -0700
commit3b4656645f551f0ebe8b5c7e8660992bc88de123 (patch)
tree8672bb435ec295d833c4159e084608818b7c79b9 /test/visitors
parentbec41aa80d5977c3f9315e3761f4d364d311960d (diff)
downloadpsych-3b4656645f551f0ebe8b5c7e8660992bc88de123.zip
time can convert to ruby
Diffstat (limited to 'test/visitors')
-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')