diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-07-14 21:05:00 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-07-14 21:05:00 +0000 |
commit | b782aea75f5b9e8d49ef12b9f7fe3ef0dbf9fd51 (patch) | |
tree | 74ce8dda09c926c750c07a1ed73a51e05015d519 | |
parent | 874224888489924c3674b2f9a7c3f1caeac47400 (diff) | |
download | ruby-b782aea75f5b9e8d49ef12b9f7fe3ef0dbf9fd51.tar.gz |
* time.c (guess_local_offset): use the UTC offset of an older date on
64bit time_t environment.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | test/ruby/test_time_tz.rb | 7 | ||||
-rw-r--r-- | time.c | 11 |
3 files changed, 20 insertions, 3 deletions
@@ -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]) @@ -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; } |