[squeak-dev] Re: [Pharo-project] Epoch returns local offset

David T. Lewis lewis at mail.msen.com
Sat May 19 03:44:18 UTC 2012


On Fri, May 18, 2012 at 04:55:39PM -0700, Eliot Miranda wrote:
> On Fri, May 18, 2012 at 4:47 PM, David T. Lewis <lewis at mail.msen.com> wrote:
> 
> > On Fri, May 18, 2012 at 09:30:32PM +0200, Bert Freudenberg wrote:
> > > On 18.05.2012, at 19:22, Eliot Miranda wrote:
> > >
> > > > 'From Smalltalk-80, version 2, of April 1, 1983 on 31 May 1983 at
> > 9:10:35 am'!
> > >
> > > That's obviously an April Fool's joke ;)
> > >
> > >
> > > But very interesting indeed. I had assumed that the way Squeak handles
> > > time is identical to how Smalltalk-80 did it. Apparently not, they must
> > > have simplified in the Mac version.
> > >
> > > - Bert -
> > >
> >
> > The original Squeak implementation of Time class>>totalSeconds uses
> > primSecondsClock, which is documented as:
> >
> > primSecondsClock
> >        "Answer the number of seconds since 00:00 on the morning of
> >         January 1, 1901 (a 32-bit unsigned number).
> >         Essential. See Object documentation whatIsAPrimitive. "
> >
> > This does not specify whether it refers to the local time zone or to GMT,
> > and the actual implementation in Squeak has always used local time.
> >
> > The Blue Book documents Time class>totalSeconds as "Answer the total
> > seconds
> > from Jan. 1, 1901, corrected for time zone and daylight savings time."
> >
> > And Time class>>timeWords is "Answer the seconds (in Greenwich Mean Time)
> > since Jan. 1, 1901 ..."
> >
> > So it certainly does sound like totalSeconds was intended to be seconds
> > since Jan. 1, 1901 GMT, and it also appears that totalSeconds has been
> > implemented differently in Squeak.
> >
> > After seeing Eliot's code reference, I'm inclined to think that the Blue
> > Book provided an unambiguous definition (though poorly worded), and that
> > Squeak has apparently been implementing it differently all along. There
> > is nothing in the Squeak image itself that gives a clue as to the original
> > intent (Time class>>timeWords is not present in Squeak), so the conflicting
> > implementations are now in wide circulation.
> >
> > None of this does much to convince me that refering to a clearly defined
> > Posix epoch would be a bad idea ...
> >
> 
> Bit it's so dull ;)  The start of the 20th century, albeit the traditional
> 01 start instead of the colloquial 00 start, is so much nicer.  I strongly
> suspect that 1970 was chosen more because of the absence of large integer
> arithmetic in libc (31 bit seconds run aground in 2038), and so is mere
> pragmatism.

There probably was no such thing as libc back then, but it was pragmatism
for sure. Assuming that the first unix system was done in the 1969-1971
time frame, and knowing that time() was one of the small set of system
calls (aka primitives) on those early systems running on limited hardware
resources (http://en.wikipedia.org/wiki/PDP-7), the choice of 1970 as
the origin for the system clock would have been a no-brainer.

It's interesting to contrast this with Smalltalk, which was invented
in the same time frame, and would have been subject to similar hardware
constraints. For Smalltalk, there was evidently been no motivation
to pack the visible time horizon into a 32-bit value, perhaps in part
because a SmallInteger is not that wide (and thus would have run aground
well before 2038), but more importantly because it is natural in Smalltalk
to handle this sort of logic in the image.

> Some of us were already born in 1970, and I hate being negative.
> 

That's an excellent point, I never thought of it in those terms. Being
well into negative terratory myself in that regard, I'm beginning to
warm up to your point of view ;)

Dave



More information about the Squeak-dev mailing list