Subject: Re: gettimeofday()
To: Christos Zoulas <christos@zoulas.com>
From: David A. Gatwood <marsmail@globegate.utm.edu>
List: port-mac68k
Date: 12/17/1997 21:53:36
On Wed, 17 Dec 1997, Christos Zoulas wrote:

> RTM. the struct tm parameter of gettimeofday is obsolete. use

Sadly, I was reading a manual, just not a *BSD manual....  Linux manual
pages are themselves obsolete, apparently, at least mine....  :-)


> #include <time.h>
> 
> ...
> 	time_t t = time(NULL);
> 	struct tm *tm = localtime(&t);
> 
> 	... tm->tm_gmtoff ...
> 
> Note, that this will work only on BSD systems.

Yeah.  Tried that on linux and the number returned made no sense, and
basically, I need it to work under both NetBSD (my portable development
platform) and MkLinux (globegate.utm.edu, the actual server).  Apparently,
that's in linux's structure, but it's undocumented and unsupported (the
value was something totally weird, and not divisible by 60, I don't
think)....

Anyway, I did find a solution (though it's not quite finished, as I
haven't gotten support for +13 and -13 GMT biases working yet) that does a
localtime and a gmtime and compares the hours (and minutes to make sure
that there wasn't a change in hours between the two calls, and days to
figure out if it's -11 or +13) and thus determines the GMT bias.  It's
big, but it works.


David

-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/CC/FA/H/L/MC/M/MU/PA/TW d-@ s:>- a-- C++++>$ UBLAS*++++>$
P+?>$ L+++>$ !E--- W+++>$ N++(+++)>+++$ !o? K-? !w--- !O
M++>$ !V-- PS+>$ !PE- Y+>$ PGP+>$ t+++>$ 5+>++++$ !X- !R tv+>$
b++>$ !DI !D- G++(+++)>$ e>++++ h--! r--- !y-
------END GEEK CODE BLOCK------