summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-03-30 11:41:39 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-03-30 11:41:39 +0000
commitbbf04edb3821897a843406dff552b7643d5a3218 (patch)
treeba5b3bb080910754c9c28e3660add4cbf6276994 /time.c
parentb36b50a83c78496b5de02226133a7a7e7e4ac907 (diff)
* time.c (search_time_t): limit guess range by mktime if it is
available. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6050 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 d72d3a4..a81c3bb 100644
--- a/time.c
+++ b/time.c
@@ -440,6 +440,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);