[前][次][番号順一覧][スレッド一覧]

ruby-changes:5645

From: akr <ko1@a...>
Date: Fri, 13 Jun 2008 23:08:49 +0900 (JST)
Subject: [ruby-changes:5645] Ruby:r17152 (ruby_1_8): * lib/time.rb (Time.xmlschema): don't accept decimal dot

akr	2008-06-13 23:08:38 +0900 (Fri, 13 Jun 2008)

  New Revision: 17152

  Modified files:
    branches/ruby_1_8/ChangeLog
    branches/ruby_1_8/lib/time.rb

  Log:
    * lib/time.rb (Time.xmlschema): don't accept decimal dot
      without fractional digits.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/ChangeLog?r1=17152&r2=17151&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/lib/time.rb?r1=17152&r2=17151&diff_format=u

Index: ruby_1_8/ChangeLog
===================================================================
--- ruby_1_8/ChangeLog	(revision 17151)
+++ ruby_1_8/ChangeLog	(revision 17152)
@@ -1,3 +1,8 @@
+Fri Jun 13 23:08:02 2008  Tanaka Akira  <akr@f...>
+
+	* lib/time.rb (Time.xmlschema): don't accept decimal dot
+	  without fractional digits.
+
 Fri Jun 13 14:24:37 2008  Nobuyoshi Nakada  <nobu@r...>
 
 	* gc.c (rb_memerror): exit with EXIT_FAILURE instead of magic number.
Index: ruby_1_8/lib/time.rb
===================================================================
--- ruby_1_8/lib/time.rb	(revision 17151)
+++ ruby_1_8/lib/time.rb	(revision 17152)
@@ -353,7 +353,7 @@
           (-?\d+)-(\d\d)-(\d\d)
           T
           (\d\d):(\d\d):(\d\d)
-          (\.\d*)?
+          (\.\d+)?
           (Z|[+-]\d\d:\d\d)?
           \s*\z/ix =~ date
         year = $1.to_i
@@ -528,6 +528,9 @@
                    Time.httpdate("Tue, 15 Nov 1994 12:45:26 GMT"))
       assert_equal(Time.utc(1999, 12, 31, 23, 59, 59),
                    Time.httpdate("Fri, 31 Dec 1999 23:59:59 GMT"))
+
+      assert_equal(Time.utc(2007, 12, 23, 11, 22, 33),
+                   Time.httpdate('Sunday, 23-Dec-07 11:22:33 GMT'))
     end
 
     def test_rfc3339
@@ -598,6 +601,7 @@
                    Time.xmlschema("2000-01-12T12:13:14Z"))
       assert_equal(Time.utc(2001, 4, 17, 19, 23, 17, 300000),
                    Time.xmlschema("2001-04-17T19:23:17.3Z"))
+      assert_raise(ArgumentError) { Time.xmlschema("2000-01-01T00:00:00.+00:00") }
     end
 
     def test_encode_xmlschema
@@ -786,6 +790,10 @@
       assert_equal(t, Time.xmlschema("1998-12-31T23:00:00-01:00"))
     end
 
+    def test_xmlschema_fraction
+      assert_equal(500000, Time.xmlschema("2000-01-01T00:00:00.5+00:00").tv_usec)
+    end
+
     def test_ruby_talk_152866
       t = Time::xmlschema('2005-08-30T22:48:00-07:00')
       assert_equal(31, t.day)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]