Flowdock
method

test_encode_xmlschema

Importance_0
v1_9_1_378 - Show latest stable - 0 notes - Class: TimeExtentionTest
test_encode_xmlschema() public

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Hide source
# File lib/time.rb, line 648
    def test_encode_xmlschema
      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))

      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))

      begin
        Time.at(-1)
      rescue ArgumentError
        # ignore
      else
        t = Time.utc(1960, 12, 31, 23, 0, 0, 123456)
        assert_equal("1960-12-31T23:00:00.123456Z", t.xmlschema(6))
      end

      assert_equal(249, Time.xmlschema("2008-06-05T23:49:23.000249+09:00").usec)
    end
Register or log in to add new notes.