[1548] in Coldmud discussion meeting

root meeting help first first in chain previous in chain previous next last

Re: 1.1.8 Win32 genesis binaries

daemon@ATHENA.MIT.EDU (Sun Jan 23 18:14:28 2000 )

From: "Jon A. Lambert" <jlsysinc@ix.netcom.com>
To: <coldstuff@cold.org>
Date: Sun, 23 Jan 2000 18:06:41 -0500
Reply-To: coldstuff@cold.org

Psyclone wrote:
>"Jon A. Lambert" wrote:
>> 
>> 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:
>

I'm not sure what the specs on gettimeofday() since it's not supported on
WIN32, but this may be an adequate substitution. 

void gettimeofday(struct timeval* tp)
{
  timeb tm;
  ftime(&tm);
  tp->tv_sec  = tm.time;
  tp->tv_usec = tm.millitm * 1000;
}

Yes microseconds are not supported on WIN32.

I had a problem in timestamping transactions on an IBM 3090
where the granularity of millsecs was not enough to avoid collisions.
If that is the case then something like the following will help:

void gettimeofday(struct timeval* tp)
{
  static int counter;  
  timeb tm;
  counter++;
  ftime(&tm);
  tp->tv_sec  = tm.time;
  tp->tv_usec = (tm.millitm * 1000) + counter;
}
 
>(Oops, it always returns -1) Anyway, I guess I can have it return
>milliseconds * 1000. Something's better than nothing..
>
>> 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)?

It depends.  If ctime(0) on Unix returns "January 1st, 1970 00:00:00" if
you reside in the EST timezone, isn't that also misleading?
Should it not return "December 31st 1969 19:00:00"? 
What does Unix return for values between 0-18000, assuming you reside
in EST5EDT land? 

Or you could just:
if (tval < _timezome) THROW(ERROR);

--
--*     Jon A. Lambert - TychoMUD Email: jlsysinc@nospam.ix.netcom.com     *--
--*     Mud Server Developer's Page <http://jlsysinc.home.netcom.com>      *--
--* "No Free man shall ever be debarred the use of arms." Thomas Jefferson *--