[BUG] Chronology DateAndTime class>>now returns incorrect time

David T. Lewis lewis at mail.msen.com
Sat Feb 21 21:07:05 UTC 2004


On Sat, Feb 21, 2004 at 10:04:25AM -0800, Timothy Rowledge wrote:
> 
> On Feb 21, 2004, at 6:47 AM, Hans-Martin Mosner wrote:
> > The problem is that DateAndTime class>>now incorrectly assumes that 
> > the millisecondClockValue only counts from 0 to 999 within one step of 
> > the totalSeconds.
> > But the millisecondClockValue just counts up from the system startup, 
> > and is not even synchronized to totalSeconds (so taking 
> > millisecondClockValue\\1000 does not help).
> Oh good grief. That was a really silly assumption on somebody's part.
> 
> If it is really considered important to have micro/nano second 
> resolution in times we will want a new primitive that (for example) 
> returns effectively the same as that unix call that gives the seconds 
> and milliseconds etc. I'd doubt there are many OS calls that give 
> reliable nanosecond results though While we're thinking about it, it 
> might be useful to consider an optional prim that can make use of 
> functions like gmtime() since that leaves the tricky arithmetic to 
> someone else.

Nanosecond precision:
I think that the point of DateAndTime is in part to provide an ANSI
compliant protocol. It really doesn't matter whether the result is
accurate to nanosecond precision, but it probably does matter that
DateAndTime is precise (as opposed to accurate) to nanosecond
precision. I'm not saying that the ANSI protocol necessarily is a
great way to express time, but if we're going to provide the protocol,
let's not do it almost right.

So it's an implementation bug, not a design bug, and the Way of
Least Work is to fix the implementation bug.

gmtime():
Hmmm, I think Lex and I came up with a simple primitive to do this
quite a long time ago. Lex posted a simple implemention, and I think
I had previously put out a more complicated one (see the plugin
provided in TimeZoneDatabase on SM).  Maybe I'll see if I can still
find Lex's old posting, I think it does exactly what you are suggesting.

Dave




More information about the Squeak-dev mailing list