aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--test/ruby/test_time_tz.rb7
-rw-r--r--time.c11
3 files changed, 20 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index f3b5807dff..9e26082cb4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Jul 15 06:01:42 2010 Tanaka Akira <akr@fsij.org>
+
+ * 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@tenderlovemaking.com>
* lib/test/unit.rb (setup_argv): convert to using optparse, adding
diff --git a/test/ruby/test_time_tz.rb b/test/ruby/test_time_tz.rb
index ee87eac0c0..42c4607bf3 100644
--- a/test/ruby/test_time_tz.rb
+++ b/test/ruby/test_time_tz.rb
@@ -80,7 +80,6 @@ class TestTimeTZ < Test::Unit::TestCase
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 @@ class TestTimeTZ < Test::Unit::TestCase
}
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])
diff --git a/time.c b/time.c
index 10ec037373..0a32f4f1a5 100644
--- a/time.c
+++ b/time.c
@@ -1506,8 +1506,15 @@ guess_local_offset(struct vtm *vtm_utc, int *isdst_ret, const char **zone_ret)
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;
}