Feature #10459 ยป rfc3339.patch
lib/time.rb (working copy)  

# === Converting to a String


#


# t = Time.now


# t.iso8601 # => "20111005T22:26:1204:00"


# t.rfc2822 # => "Wed, 05 Oct 2011 22:26:12 0400"


# t.httpdate # => "Thu, 06 Oct 2011 02:26:12 GMT"


# t.rfc3339(9) # => "20111005T22:26:12.99699260904:00"


# t.rfc3339 # => "20111005T22:26:1204:00"


# t.iso8601(9) # => "20111005T22:26:12.99699260904:00"


# t.iso8601 # => "20111005T22:26:1204:00"


# t.rfc2822 # => "Wed, 05 Oct 2011 22:26:12 0400"


# t.httpdate # => "Thu, 06 Oct 2011 02:26:12 GMT"


#


# === Time.parse


#


...  ...  
end


end


alias iso8601 xmlschema


alias rfc3339 xmlschema


end # class << self


#

test/test_time.rb (working copy)  

def test_rfc3339


t = Time.utc(1985, 4, 12, 23, 20, 50, 520000)


s = "19850412T23:20:50.52Z"


assert_equal(t, Time.iso8601(s))


assert_equal(s, t.iso8601(2))


assert_equal(t, Time.rfc3339(s))


assert_equal(s, t.rfc3339(2))


t = Time.utc(1996, 12, 20, 0, 39, 57)


s = "19961219T16:39:5708:00"


assert_equal(t, Time.iso8601(s))


assert_equal(t, Time.rfc3339(s))


# There is no way to generate time string with arbitrary timezone.


s = "19961220T00:39:57Z"


assert_equal(t, Time.iso8601(s))


assert_equal(s, t.iso8601)


assert_equal(t, Time.rfc3339(s))


assert_equal(s, t.rfc3339)


t = Time.utc(1990, 12, 31, 23, 59, 60)


s = "19901231T23:59:60Z"


assert_equal(t, Time.iso8601(s))


assert_equal(t, Time.rfc3339(s))


# leap second is representable only if timezone file has it.


s = "19901231T15:59:6008:00"


assert_equal(t, Time.iso8601(s))


assert_equal(t, Time.rfc3339(s))


begin


Time.at(1)


...  ...  
else


t = Time.utc(1937, 1, 1, 11, 40, 27, 870000)


s = "19370101T12:00:27.87+00:20"


assert_equal(t, Time.iso8601(s))


assert_equal(t, Time.rfc3339(s))


end


end
