summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-04-16 10:12:06 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-04-16 10:12:06 +0000
commit4b3d078462f3d9306e56649bd818e0f54c214f18 (patch)
treec4e970ea2c1adb8e2882a2591d0abba11a378668 /time.c
parente2a513c54e6792270468fd13b926d83f9f643f5f (diff)
gettimeofday buf on alpha
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r--time.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/time.c b/time.c
index f4bb8bfbc2e..2645b3ce0f6 100644
--- a/time.c
+++ b/time.c
@@ -36,8 +36,8 @@ int gettimeofday(struct timeval*, struct timezone*);
int strcasecmp(char*, char*);
#endif
-#if 0
-#include <math.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
#endif
VALUE rb_cTime;
@@ -469,9 +469,10 @@ time_localtime(time)
{
struct time_object *tobj;
struct tm *tm_tmp;
- time_t t = tobj->tv.tv_sec;
+ time_t t;
GetTimeval(time, tobj);
+ t = tobj->tv.tv_sec;
tm_tmp = localtime(&t);
tobj->tm = *tm_tmp;
tobj->tm_got = 1;
@@ -485,9 +486,10 @@ time_gmtime(time)
{
struct time_object *tobj;
struct tm *tm_tmp;
- time_t t = tobj->tv.tv_sec;
+ time_t t;
GetTimeval(time, tobj);
+ t = tobj->tv.tv_sec;
tm_tmp = gmtime(&t);
tobj->tm = *tm_tmp;
tobj->tm_got = 1;
@@ -535,12 +537,12 @@ time_to_s(time)
}
#ifndef HAVE_TM_ZONE
if (tobj->gmt == 1) {
- len = strftime(buf, 128, "%a %b %d %H:%M:%S GMT %Y", &(tobj->tm));
+ len = strftime(buf, 128, "%a %b %d %H:%M:%S GMT %Y", &tobj->tm);
}
else
#endif
{
- len = strftime(buf, 128, "%a %b %d %H:%M:%S %Z %Y", &(tobj->tm));
+ len = strftime(buf, 128, "%a %b %d %H:%M:%S %Z %Y", &tobj->tm);
}
return rb_str_new(buf, len);
}
@@ -742,7 +744,7 @@ time_zone(time)
time_get_tm(time, tobj->gmt);
}
- len = strftime(buf, 64, "%Z", &(tobj->tm));
+ len = strftime(buf, 64, "%Z", &tobj->tm);
return rb_str_new(buf, len);
}
@@ -828,7 +830,7 @@ time_strftime(time, format)
str = rb_str_new(0, 0);
while (p < pe) {
- len = rb_strftime(&buf, p, &(tobj->tm));
+ len = rb_strftime(&buf, p, &tobj->tm);
rb_str_cat(str, buf, len);
p += strlen(p) + 1;
if (p <= pe)
@@ -837,7 +839,7 @@ time_strftime(time, format)
}
return str;
}
- len = rb_strftime(&buf, RSTRING(format)->ptr, &(tobj->tm));
+ len = rb_strftime(&buf, RSTRING(format)->ptr, &tobj->tm);
str = rb_str_new(buf, len);
if (buf != buffer) free(buf);
return str;
@@ -888,12 +890,13 @@ time_dump(argc, argv, time)
struct tm *tm;
unsigned long p, s;
unsigned char buf[8];
- time_t t = tobj->tv.tv_sec;
+ time_t t;
int i;
rb_scan_args(argc, argv, "01", &dummy);
GetTimeval(time, tobj);
+ t = tobj->tv.tv_sec;
tm = gmtime(&t);
p = 0x1 << 31 | /* 1 */