[squeak-dev] DateAndTimeLeapTest>>testAsSeconds is broken

David T. Lewis lewis at mail.msen.com
Fri Dec 2 03:03:25 UTC 2016


On Thu, Dec 01, 2016 at 04:53:24PM +0100, Bert Freudenberg wrote:
> On Thu, Dec 1, 2016 at 4:17 PM, Bert Freudenberg <bert at freudenbergs.de>
> wrote:
> 
> > On Thu, Dec 1, 2016 at 2:29 PM, David T. Lewis <lewis at mail.msen.com>
> > wrote:
> >
> >> On Thu, Dec 01, 2016 at 11:07:45AM +0100, Bert Freudenberg wrote:
> >>
> > Here I am raising a different (but admittedly related) question. How many
> >> seconds
> >> elapsed between the Smalltalk epoch and the time
> >> 2004-02-29T13:33:00+02:00?
> >>
> >
> > => 3255507180 <(325)%20550-7180> + DateAndTime localOffset asSeconds
> >
> > My reasoning:
> >
> > ('1901-01-01T00:00:00+02:00' asDateAndTime - DateAndTime epoch) asSeconds
> >  = (0 + DateAndTime localOffset asSeconds - 7200)
> >
> > and so
> >
> > ('2004-02-29T13:33:00+02:00' asDateAndTime - DateAndTime epoch) asSeconds
> > = (3255514380 <(325)%20551-4380> + DateAndTime localOffset asSeconds -
> > 7200)
> >
> > It can't be a constant but needs to take into account the local time zone.
> > Because Smalltalk epoch is defined as local time, the difference to a fixed
> > time necessarily involves the timezone offset.
> >
> 
> Ah, but #asSeconds uses the epoch in the time zone of that DateAndTime
> instance, so it *is* a constant after all ... But it's not constant wrt
> your own local time zone.

Right. Neither of which makes any logical sense, because even if you wanted
to define "epoch" relative to your local time zone, its value would change
the next time you encounter a daylight savings time transition. And if you
think that your "epoch" is relative to the offset of a DateAndTime instance
that may or may not have been created in your local time zone, then that is
another "epoch" entirely.

Furthermore, an instance of DateAndTime does not have a time zone, it has
an offset, which is not the same thing at all. The offset for any given
DateAndTime may or may not correspond to the time zone in which your Squeak
image happens to be running. And the offset for any given time zone will vary
as a function of time due to daylight savings time rules and other political
factors (in the real world, not in Squeak).

> 
> Then again, maybe fromSeconds: and asSeconds should be symmetric. They're
> not, because asSeconds uses the instance's time zone, but fromSeconds: uses
> local time zone.

Right. At the very least it should be symmetric.

> 
> It's also quit possible I'm totally confused - I did not use independent
> resources but was just relying on Squeak.
> 

Well yes, of course you are confused, you should be. I would have been very
worried if you looked at this and thought that it made any sense ;-)

Dave



More information about the Squeak-dev mailing list