summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-05-16 09:05:54 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-05-16 09:05:54 +0000
commitf84f4aa6b375290386c0456ac02fe8f6cc2cdd2d (patch)
treefba985cc67803c80f7761462f79cf988cbf6507b /time.c
parent59d82a928a617889c18f4da6152f11c0eb6fde06 (diff)
downloadruby-f84f4aa6b375290386c0456ac02fe8f6cc2cdd2d.tar.gz
* 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@1399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r--time.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/time.c b/time.c
index 8e79080380..dd3b6eb666 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;