mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
8742248884
commit
b782aea75f
3 changed files with 20 additions and 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
|
||||
|
|
|
@ -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])
|
||||
|
|
9
time.c
9
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)
|
||||
# if SIZEOF_TIME_T <= 4
|
||||
/* 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)) {
|
||||
# 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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue