Millisecond clock resolution for DateAndTime now

lex at cc.gatech.edu lex at cc.gatech.edu
Sun Sep 26 21:40:17 UTC 2004


John M McIntosh <johnmci at smalltalkconsulting.com> wrote:
> I guess one could lobby for
> unix (tm) gettimeofday()
> for 3.9
> This could even be via a plugin, or FFI call...

I agree.  gettimeofday() can give you microsecond precision and timezone
information.

And while we're at it, how about adjusting the primitive's *interface*
to ask for the UTC offset as well?  The get-time primitive would then
return two things:

	1. The time, probably as approximately[1] the number of seconds since
some epoch.
	
	2. The offset in seconds to get to UTC time.
	
Note that if you want UTC time, you cannot ask for the local time and
then ask for the offset separately, because the offset changes as the
year goes on.  You need to ask for them simultaneously.

It so happens that gettimeofday() gives you the info simultaneously, so
it's just a matter of copying it upwards.

UTC matters when Squeak is operating over the Internet, e.g. when people
use Celeste.


-Lex

[1] The exact calculation is annoying if you account for leap days and
leap seconds, but there's no reason to do it exactly that way.  It's
just an encoding, so the encoding can be something like:

	seconds + (minutes * 61) + (hours * 61 * 60) + (days * 61 * 60 * 24) +
etc.



More information about the Squeak-dev mailing list