[squeak-dev] Re: Date[And]Time fractional seconds printing

Colin Putney cputney at wiresong.ca
Thu Aug 19 16:37:39 UTC 2010


On 2010-08-19, at 4:56 AM, David T. Lewis wrote:

> I don't know the reason for carrying nanoseconds. With respect to
> complexity, the nanosecond implementation is no more complex than
> would be the case for microseconds, and I don't think it has any
> additional computational penalty, so my guess would be that nanoseconds
> were chosen in order to provide essentially unlimited precision.
> 
> To my mind, the more worthwhile simplification would be to represent
> time as a magnitude (one number, rather than jdn, seconds, nanos and
> offset). In other words, keep the protocol for DateAndTime the
> same but let the underlying representation be a Number of seconds
> UTC since the epoch. This would simplify time arithmetic (think
> calculation of duration across a daylight savings time transition),
> and I suspect that it might help performance, given the heavy use
> of time stamps in source files, Monticello, etc. But it would
> be a lot of work to implement this, and I have never gotten around
> to trying it.

I've done this. The MDTimestamp class in Monticello 2.x is a subclass of Magnitude. Internally it's organized as a 4-byte value representing the number of seconds since March 1, 1980. There's also a (slightly incomplete) MDTimestampPrinter class that prints timestamps using format strings similar to strftime(). The approach worked out quite well.

Colin


More information about the Squeak-dev mailing list