Millisecond clock resolution for DateAndTime now

David T. Lewis lewis at mail.msen.com
Mon Sep 27 01:50:49 UTC 2004


On Sun, Sep 26, 2004 at 03:58:43PM -0700, Tim Rowledge wrote:
> "David T. Lewis" <lewis at mail.msen.com> wrote:
> 
> [snip]
> > That's exactly what Lex is suggesting.
> 
> That might be what he meant but it isn't what he wrote... I quote...
> >> . The time, probably as approximately[1] the number of seconds since
> > > some epoch.

Tim,

Obviously you have been lulled into a false sense of security by the
media.  The world is a wobbly place, full of uncertainty and all manner
of imprecision.

Having paid quite close attention to these matters, I count no fewer
than 22 leap seconds that have occurred since Jan 1, 1970 UTC.  Some
of these cosmic recalibrations may have entirely escaped the notice
of the less attentive among us, accounting for a general uncertainty
as to where any of us really stands on the cosmic timeline. Small wonder
if Lex may have felt a bit off center with regard to time primitives; it
happens to all of us with advancing age. You really aught to be more
sensitive about these things.

> Whereas I meant filling in an array of                                    
>   int tm_sec;
>   int tm_min;
>   int tm_hour;
>   int tm_mday;
>   int tm_mon;
>   int tm_year;
>   int tm_wday;
>   int tm_yday;
>   int tm_isdst;

Well then, that's a horse of a different color. It's easy to be precise
if one squints one's eyes and focuses only on the present.
 ;-)

> Or whatever is suitable to the typical call. The above is RISC OS's
> gmtime() equivalent. I'd need to find the DST offset as well I guess.

gmtime() has precision to the nearest second. Does RISC OS provide a
gettimeofday() function? This is a BSD function that answers time to
millisecond precision, and also provides the time zone offset and a
flag denoting daylight savings time. If this or something like it is
available on RISC OS, then it should be possible to implement Lex's
suggestion on all the major Squeak platforms.

Dave




More information about the Squeak-dev mailing list