[1547] in Coldmud discussion meeting
Re: 1.1.8 Win32 genesis binaries
daemon@ATHENA.MIT.EDU (Sun Jan 23 13:04:52 2000
)
Date: Sun, 23 Jan 2000 12:42:33 -0500
From: Psyclone <psyclone42@geocities.com>
To: coldstuff@cold.org
Reply-To: coldstuff@cold.org
"Jon A. Lambert" wrote:
>
> >Psyclone wrote:
> >>
> >>mtime() always returns 0. Also a library issue -- Win32 apparently
> >>doesn't have a function to return microseconds.
> >
> >Hmm.. I'll have a look around.
> >
>
> Sorry I don't have the current source handy, but ...
>
> Not sure where you need it but this will pull out current millisecs (~=microsecs?).
Milliseconds (msec) are 1/1000ths of a second, Microseconds (usec --
actually the greek letter mu instead of u) are 1/1000000ths of a second.
mtime() is used in-core to time evals:
<source>
void func_mtime(void) {
#ifdef HAVE_GETTIMEOFDAY
struct timeval tp;
#endif
if (!func_init_0())
return;
#ifdef HAVE_GETTIMEOFDAY
/* usec is microseconds */
gettimeofday(&tp, NULL);
push_int((cNum) tp.tv_usec);
#else
push_int(-1);
#endif
}
</source>
(Oops, it always returns -1) Anyway, I guess I can have it return
milliseconds * 1000. Something's better than nothing..
> >>ctime() and friends throw when given numbers < 18000. Borland (what I
> >>used to compile genesis) has a broken time utility which causes genesis
> >>to crash when these functions are given low numbers.
> >>
>
> This check will resolve the problem without having to throw an error and
> should work in whatever timezone you set up in.
>
> Somewhere after this :
> tval = (num_args) ? args[0].u.val : time(NULL);
>
> Insert the following:
> #ifdef _BORLANDC_
> if (tval < _timezome) tval = _timezone;
> #endif
>
> Before calling:
> ctime(tval);
>
Isn't it a bit misleading, though, to have ctime(0) return the same as
(say) ctime(18000)?