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

ruby-changes:16596

From: akr <ko1@a...>
Date: Fri, 9 Jul 2010 20:34:04 +0900 (JST)
Subject: [ruby-changes:16596] Ruby:r28588 (trunk): * time.c (find_time_t): 24:00 should be the beginning of the next

akr	2010-07-09 20:33:46 +0900 (Fri, 09 Jul 2010)

  New Revision: 28588

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=28588

  Log:
    * time.c (find_time_t): 24:00 should be the beginning of the next
      day even if the leap second, 23:59:60, exists.

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_time_tz.rb
    trunk/time.c

Index: time.c
===================================================================
--- time.c	(revision 28587)
+++ time.c	(revision 28588)
@@ -2928,6 +2928,7 @@
             return NULL;
 	}
     }
+
     /* Given argument has no corresponding time_t. Let's outerpolation. */
     /*
      *  `Seconds Since the Epoch' in SUSv3:
@@ -2950,7 +2951,7 @@
            tm_lo.tm_yday) * 86400 +
           (tptr->tm_hour - tm_lo.tm_hour) * 3600 +
           (tptr->tm_min - tm_lo.tm_min) * 60 +
-          (tptr->tm_sec - tm_lo.tm_sec);
+          (tptr->tm_sec - (tm_lo.tm_sec == 60 ? 59 : tm_lo.tm_sec));
 
     return NULL;
 
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 28587)
+++ ChangeLog	(revision 28588)
@@ -1,3 +1,8 @@
+Fri Jul  9 20:30:26 2010  Tanaka Akira  <akr@f...>
+
+	* time.c (find_time_t): 24:00 should be the beginning of the next
+	  day even if the leap second, 23:59:60, exists.
+
 Fri Jul  9 01:08:46 2010  Aaron Patterson <aaron@t...>
 
 	* ext/psych/lib/psych/visitors/emitter.rb (initialize): line_width is
Index: test/ruby/test_time_tz.rb
===================================================================
--- test/ruby/test_time_tz.rb	(revision 28587)
+++ test/ruby/test_time_tz.rb	(revision 28588)
@@ -147,6 +147,23 @@
     }
   end
 
+  def test_right_utc
+    with_tz(tz="right/UTC") {
+      assert_time_constructor(tz, "2008-12-31 23:59:59 UTC", :utc, [2008,12,31,23,59,59])
+      assert_time_constructor(tz, "2008-12-31 23:59:60 UTC", :utc, [2008,12,31,23,59,60])
+      assert_time_constructor(tz, "2009-01-01 00:00:00 UTC", :utc, [2008,12,31,24,0,0])
+      assert_time_constructor(tz, "2009-01-01 00:00:00 UTC", :utc, [2009,1,1,0,0,0])
+    }
+  end
+
+  def test_right_america_los_angeles
+    with_tz(tz="right/America/Los_Angeles") {
+      assert_time_constructor(tz, "2008-12-31 15:59:59 -0800", :local, [2008,12,31,15,59,59])
+      assert_time_constructor(tz, "2008-12-31 15:59:60 -0800", :local, [2008,12,31,15,59,60])
+      assert_time_constructor(tz, "2008-12-31 16:00:00 -0800", :local, [2008,12,31,16,0,0])
+    }
+  end
+
   MON2NUM = {
     "Jan" => 1, "Feb" => 2, "Mar" => 3, "Apr" => 4, "May" => 5, "Jun" => 6,
     "Jul" => 7, "Aug" => 8, "Sep" => 9, "Oct" => 10, "Nov" => 11, "Dec" => 12

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

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