From db52e5b5ecd6a47d2be539030686ca92d2b2c417 Mon Sep 17 00:00:00 2001 From: matz Date: Wed, 16 May 2001 09:05:54 +0000 Subject: * array.c (rb_ary_and): should not push frozen key string. * array.c (rb_ary_or): ditto. * eval.c (rb_thread_schedule): should save context before raising deadlock, saved context for current thread might be obsolete. * time.c (make_time_t): non DST timezone shift supported (hopefully). * time.c (make_time_t): strict range detection for negative time_t. * signal.c: SIGINFO added. * eval.c (rb_ensure): should not SEGV when prot_tag is NULL. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@1399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- time.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'time.c') diff --git a/time.c b/time.c index 8e7908038..dd3b6eb66 100644 --- a/time.c +++ b/time.c @@ -328,8 +328,6 @@ make_time_t(tptr, utc_p) guess += (tptr->tm_sec - tm->tm_sec); #ifndef NEGATIVE_TIME_T if (guess < 0) goto out_of_range; -#else - if (oguess > 365 * 24 * 3600 && guess < 0) goto out_of_range; #endif if (!utc_p) { /* localtime zone adjust */ @@ -362,17 +360,32 @@ make_time_t(tptr, utc_p) tm = localtime(&guess); if (!tm) goto error; if (lt.tm_isdst != tm->tm_isdst || tptr->tm_hour != tm->tm_hour) { - oguess = guess - 3600; - tm = localtime(&oguess); + time_t tmp = guess - 3600; + tm = localtime(&tmp); if (!tm) goto error; if (tptr->tm_hour == tm->tm_hour) { - guess = oguess; + guess = tmp; + } + else if (lt.tm_isdst == tm->tm_isdst) { + tmp = guess + 3600; + tm = localtime(&tmp); + if (!tm) goto error; + if (tptr->tm_hour == tm->tm_hour) { + guess = tmp; + } } } + if (tptr->tm_min != tm->tm_min) { + guess += (tptr->tm_min - tm->tm_min) * 60; + } #ifndef NEGATIVE_TIME_T if (guess < 0) goto out_of_range; #endif } +#ifdef NEGATIVE_TIME_T + if (oguess > 365 * 24 * 3600 && guess < 0) goto out_of_range; + if (guess > 365 * 24 * 3600 && oguess < 0) goto out_of_range; +#endif return guess; -- cgit