diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-03-30 11:31:44 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-03-30 11:31:44 +0000 |
commit | 7bb7e17675846bd0caa7b3ad0ff1815cd313ed4f (patch) | |
tree | 70da01c74f0acc4466b9eade58dc79627a6fdcfc /time.c | |
parent | 7c34ed846fc29d34638857e4372e7b98c4f4fbe0 (diff) | |
download | ruby-7bb7e17675846bd0caa7b3ad0ff1815cd313ed4f.tar.gz |
* time.c (search_time_t): limit guess range by mktime if it is
availabe.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6049 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r-- | time.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -444,6 +444,15 @@ search_time_t(tptr, utc_p) (1UL << (8 * sizeof(time_t) - 1)) - 1 : ~(time_t)0; +#if defined(HAVE_MKTIME) + if ((guess = mktime(tptr)) != -1) { + if (guess_lo < guess - 24 * 60 * 60) + guess_lo = guess - 24 * 60 * 60; + if (guess + 24 * 60 * 60 < guess_hi) + guess_hi = guess + 24 * 60 * 60; + } +#endif + tm = (utc_p ? gmtime : localtime)(&guess_lo); if (!tm) goto error; d = tmcmp(tptr, tm); |