summaryrefslogtreecommitdiffstats
path: root/time.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-03-30 11:31:44 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-03-30 11:31:44 +0000
commit2170676ebeb934f1c0cb6dc328ad885bb9aa0108 (patch)
tree70da01c74f0acc4466b9eade58dc79627a6fdcfc /time.c
parentcdc1f55e42568148b6026120db922e770eefe5a5 (diff)
downloadruby-2170676ebeb934f1c0cb6dc328ad885bb9aa0108.tar.gz
ruby-2170676ebeb934f1c0cb6dc328ad885bb9aa0108.tar.xz
ruby-2170676ebeb934f1c0cb6dc328ad885bb9aa0108.zip
* time.c (search_time_t): limit guess range by mktime if it is
availabe. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@6049 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r--time.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/time.c b/time.c
index 0e9fb2faa..8ae8c05a2 100644
--- a/time.c
+++ b/time.c
@@ -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);