summaryrefslogtreecommitdiff
path: root/test/test_time.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-28 08:16:03 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-28 08:16:03 +0000
commit007b7fcdcf709cbffb2ee2c6c01f9edf4daaccac (patch)
tree317fa97f5d4a0af78e9c9cbf1888dffcbdb6fb66 /test/test_time.rb
parent3ee4c4fdf0250181fd1438b1e2cd5b3bcdc5f0e5 (diff)
* lib/time.rb (Time#xmlschema): use strftime specifiers instead of
fractional exponential calcuation which yields undesirable result. [ruby-core:42997][Bug #6100] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/test_time.rb')
-rw-r--r--test/test_time.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/test_time.rb b/test/test_time.rb
index 9dbce3f..0a4e8a7 100644
--- a/test/test_time.rb
+++ b/test/test_time.rb
@@ -154,22 +154,28 @@ class TestTimeExtension < Test::Unit::TestCase # :nodoc:
end
def test_encode_xmlschema
+ bug6100 = '[ruby-core:42997]'
+
t = Time.utc(2001, 4, 17, 19, 23, 17, 300000)
assert_equal("2001-04-17T19:23:17Z", t.xmlschema)
assert_equal("2001-04-17T19:23:17.3Z", t.xmlschema(1))
assert_equal("2001-04-17T19:23:17.300000Z", t.xmlschema(6))
assert_equal("2001-04-17T19:23:17.3000000Z", t.xmlschema(7))
+ assert_equal("2001-04-17T19:23:17.3Z", t.xmlschema(1.9), bug6100)
t = Time.utc(2001, 4, 17, 19, 23, 17, 123456)
assert_equal("2001-04-17T19:23:17.1234560Z", t.xmlschema(7))
assert_equal("2001-04-17T19:23:17.123456Z", t.xmlschema(6))
assert_equal("2001-04-17T19:23:17.12345Z", t.xmlschema(5))
assert_equal("2001-04-17T19:23:17.1Z", t.xmlschema(1))
+ assert_equal("2001-04-17T19:23:17.1Z", t.xmlschema(1.9), bug6100)
t = Time.at(2.quo(3)).getlocal("+09:00")
assert_equal("1970-01-01T09:00:00.666+09:00", t.xmlschema(3))
assert_equal("1970-01-01T09:00:00.6666666666+09:00", t.xmlschema(10))
assert_equal("1970-01-01T09:00:00.66666666666666666666+09:00", t.xmlschema(20))
+ assert_equal("1970-01-01T09:00:00.6+09:00", t.xmlschema(1.1), bug6100)
+ assert_equal("1970-01-01T09:00:00.666+09:00", t.xmlschema(3.2), bug6100)
t = Time.at(123456789.quo(9999999999)).getlocal("+09:00")
assert_equal("1970-01-01T09:00:00.012+09:00", t.xmlschema(3))
@@ -177,6 +183,7 @@ class TestTimeExtension < Test::Unit::TestCase # :nodoc:
assert_equal("1970-01-01T09:00:00.0123456789+09:00", t.xmlschema(10))
assert_equal("1970-01-01T09:00:00.0123456789012345678+09:00", t.xmlschema(19))
assert_equal("1970-01-01T09:00:00.01234567890123456789+09:00", t.xmlschema(20))
+ assert_equal("1970-01-01T09:00:00.012+09:00", t.xmlschema(3.8), bug6100)
t = Time.utc(1)
assert_equal("0001-01-01T00:00:00Z", t.xmlschema)