diff options
author | Jason Downs <downsj@cvs.openbsd.org> | 1997-09-15 11:29:52 +0000 |
---|---|---|
committer | Jason Downs <downsj@cvs.openbsd.org> | 1997-09-15 11:29:52 +0000 |
commit | 456f977ee0de3bfc966c959075f4bef7d2fa6278 (patch) | |
tree | 2a8b1e2b1f6e5d2684998ed876dbd57d5f5e4d9c /lib/libcompat | |
parent | 7ec33c5b4ee04184b0df48a607ffeab9d7eedf05 (diff) |
Fix NetBSD PR#4068.
Diffstat (limited to 'lib/libcompat')
-rw-r--r-- | lib/libcompat/4.1/ftime.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/libcompat/4.1/ftime.c b/lib/libcompat/4.1/ftime.c index 45c00e01c7e..deafd7099fb 100644 --- a/lib/libcompat/4.1/ftime.c +++ b/lib/libcompat/4.1/ftime.c @@ -29,12 +29,13 @@ */ #ifndef lint -static char rcsid[] = "$Id: ftime.c,v 1.2 1996/12/14 07:01:27 tholo Exp $"; +static char rcsid[] = "$Id: ftime.c,v 1.3 1997/09/15 11:29:51 downsj Exp $"; #endif /* not lint */ #include <sys/types.h> #include <sys/time.h> #include <sys/timeb.h> +#include <time.h> int ftime(tbp) @@ -42,13 +43,24 @@ ftime(tbp) { struct timezone tz; struct timeval t; + struct tm *lt; + time_t now; /* because tv_sec is a long! */ if (gettimeofday(&t, &tz) < 0) return (-1); tbp->millitm = (unsigned short)(t.tv_usec / 1000); tbp->time = t.tv_sec; - tbp->timezone = tz.tz_minuteswest; - tbp->dstflag = tz.tz_dsttime; + + time(&now); + lt = localtime(&now); + if (lt != NULL) { + tbp->timezone = -((lt->tm_isdst ? (lt->tm_gmtoff - 3600) : + lt->tm_gmtoff) / 60); + tbp->dstflag = lt->tm_isdst; + } else { + tbp->timezone = tz.tz_minuteswest; + tbp->dstflag = tz.tz_dsttime; + } return (0); } |