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

ruby-changes:16650

From: akr <ko1@a...>
Date: Thu, 15 Jul 2010 06:13:03 +0900 (JST)
Subject: [ruby-changes:16650] Ruby:r28646 (trunk): * time.c (guess_local_offset): use the UTC offset of an older date on

akr	2010-07-15 06:05:00 +0900 (Thu, 15 Jul 2010)

  New Revision: 28646

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

  Log:
    * time.c (guess_local_offset): use the UTC offset of an older date on
      64bit time_t environment.

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

Index: time.c
===================================================================
--- time.c	(revision 28645)
+++ time.c	(revision 28646)
@@ -1506,8 +1506,15 @@
         zone = "UTC";
 
 # if defined(NEGATIVE_TIME_T)
-        /* 1901-12-13 20:45:52 UTC : The oldest time in 32-bit signed time_t. */
-        if (localtime_with_gmtoff_zone((t = (time_t)0x80000000, &t), &tm, &gmtoff, &zone)) {
+#  if SIZEOF_TIME_T <= 4
+    /* 1901-12-13 20:45:52 UTC : The oldest time in 32-bit signed time_t. */
+#   define THE_TIME_OLD_ENOUGH ((time_t)0x80000000)
+#  else
+    /* Since the Royal Greenwich Observatory was commissioned in 1675,
+       no timezone defined using GMT at 1600. */
+#   define THE_TIME_OLD_ENOUGH ((time_t)(1600-1970)*366*24*60*60)
+#  endif
+        if (localtime_with_gmtoff_zone((t = THE_TIME_OLD_ENOUGH, &t), &tm, &gmtoff, &zone)) {
             off = LONG2FIX(gmtoff);
             isdst = tm.tm_isdst;
         }
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 28645)
+++ ChangeLog	(revision 28646)
@@ -1,3 +1,8 @@
+Thu Jul 15 06:01:42 2010  Tanaka Akira  <akr@f...>
+
+	* time.c (guess_local_offset): use the UTC offset of an older date on
+	  64bit time_t environment.
+
 Thu Jul 15 02:42:51 2010  Aaron Patterson <aaron@t...>
 
 	* lib/test/unit.rb (setup_argv): convert to using optparse, adding
Index: test/ruby/test_time_tz.rb
===================================================================
--- test/ruby/test_time_tz.rb	(revision 28645)
+++ test/ruby/test_time_tz.rb	(revision 28646)
@@ -80,7 +80,6 @@
     with_tz(tz="America/Los_Angeles") {
       assert_time_constructor(tz, "2007-03-11 03:00:00 -0700", :local, [2007,3,11,2,0,0])
       assert_time_constructor(tz, "2007-03-11 03:59:59 -0700", :local, [2007,3,11,2,59,59])
-      #assert_equal("PST", Time.new(-0x1_0000_0000_0000_0000).zone)
       assert_equal("PST", Time.new(0x1_0000_0000_0000_0000, 1).zone)
       assert_equal("PDT", Time.new(0x1_0000_0000_0000_0000, 8).zone)
       assert_equal(false, Time.new(0x1_0000_0000_0000_0000, 1).isdst)
@@ -136,6 +135,12 @@
     }
   end
 
+  def test_europe_lisbon
+    with_tz(tz="Europe/Lisbon") {
+      assert_equal("LMT", Time.new(-0x1_0000_0000_0000_0000).zone)
+    }
+  end
+
   def test_europe_moscow
     with_tz(tz="Europe/Moscow") {
       assert_time_constructor(tz, "1992-03-29 00:00:00 +0400", :local, [1992,3,28,23,0,0])

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

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