summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-06-16 07:44:16 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-06-16 07:44:16 +0000
commit8d18d5b3f9d96be4120b89ff743856021de84e5b (patch)
tree11462788f23b7764043dec021eee3a0ae8ad46c4 /time.c
parent1199a7d3d6399d44662b9a8bea5f359d1fdd40c2 (diff)
2000-06-16
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@760 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r--time.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/time.c b/time.c
index 6fd2fee19b..5c3dcaebf5 100644
--- a/time.c
+++ b/time.c
@@ -314,17 +314,22 @@ make_time_t(tptr, utc_or_local)
if (!utc_or_local) { /* localtime zone adjust */
#if defined(HAVE_TM_ZONE)
tm = localtime(&guess);
+ if (!tm) goto error;
guess -= tm->tm_gmtoff;
#else
struct tm gt, lt;
long tzsec;
t = 0;
- gt = *gmtime(&guess);
- lt = *localtime(&guess);
+ tm = gmtime(&guess);
+ if (!tm) goto error;
+ gt = *tm;
+ tm = localtime(&guess);
+ if (!tm) goto error;
+ lt = *tm;
tzsec = (gt.tm_min-lt.tm_min)*60 + (gt.tm_hour-lt.tm_hour)*3600;
- if(lt.tm_year > gt.tm_year) {
+ if (lt.tm_year > gt.tm_year) {
tzsec -= 24*3600;
}
else if(gt.tm_year > lt.tm_year) {
@@ -334,18 +339,17 @@ make_time_t(tptr, utc_or_local)
tzsec += (gt.tm_yday - lt.tm_yday)*24*3600;
}
- if (lt.tm_isdst) tzsec += 3600;
-
+ if (lt.tm_isdst) guess += 3600;
guess += tzsec;
if (guess < 0) {
goto out_of_range;
}
+#endif
tm = localtime(&guess);
if (!tm) goto error;
if (tm->tm_hour != tptr->tm_hour) {
guess -= 3600;
}
-#endif
if (guess < 0) {
goto out_of_range;
}