[squeak-dev] Locale & TimeZones in 4.0 image

David T. Lewis lewis at mail.msen.com
Sat Jan 12 02:04:57 UTC 2013


On Fri, Jan 11, 2013 at 05:20:57PM -0800, tim Rowledge wrote:
> The RISC OS resurrection is going well but I'm finding some interesting issues along the way, not surprisingly.
> 
> One that puzzled me yesterday was noticing that the 'Time now' was reporting GMT without any timezone correction. I don't recall this happening 'in the old days'.
> 
> I'm more than a bit confused by the huge collection of classes handling time stuff in 4.0 but so far as I could tell it makes no use whatsoever of the Locale plugin to find out the TZ - or many other - values. In fact it was hard to spot any use at all of the Locale stuff. All the other platforms appear to be returning a local time instead of a GMT value, which puzzles me since RISC OS has been using GMT since at least v1.20 in 1997!  
> 
> Does anyone remember that changing & if os, when? I guess it's a bit of a non-issue for recent images since the 'Time now' is calculated quite differently.
> 

The changes are in the image, and occurred fairly recently between Squeak 4.3 and 4.4.
Independently, the Pharo folks have done more extensive UTC related changes. The Pharo
changes sound like a good idea but last I checked I could not even get my TimeZoneDatabase
to work on it, so I gave up trying. The Squeak changes are IMO somewhat aesthetically
questionable but in practice are greatly beneficial to folks keeping track of time
stamps in databases and so forth, so I think practicality wins out here.

The underlying problem behind all this is that early Squeak VMs reported system
time in the local time zone rather than UTC, which may have made sense at the
time for single-user systems but is a mess if you want to do any kind of reasonable
time zone support or calculation of time durations. I'd love to throw the whole
thing out and start over with UTC throughout, but needless to say that would be
a non-trivial amount of work.

To find the changes, use Monticello to look in source.squeak.org/trunk in the
Kernel package (click the "history" button for a quick view). The relevant changes
were introduced in Kernel-cmm.672, Kernel-cmm.671, Kernel-cmm.670, and Kernel-cmm.669.
There was discussion about it on squeak-dev in that same time frame.

Here are two Monticello update comments that give a good summary of the changes:

    Name: Kernel-cmm.669
    Author: cmm
    Time: 3 February 2012, 5:55:11.175 pm
    UUID: 5ddec343-01ad-4e76-b32c-299fac68ec09
    Ancestors: Kernel-eem.668
    
    Introduced Timespan class>>defaultOffset.  This is the offset that will be
    used for creation of all Timespans when an offset is not specified.  When
    an offset is specified or involved in construction or calculation, the result
    is now produced in terms of the source offset.
    
    For example, Date today now produces a globalized date by default.  However,
    "Date starting: (DateAndTime year: 2004 month: 2 day: 29 hour: 13 minute:
    33 second: 0 offset: 2 hours)" produces a Date.whose start is expressed in
    terms of UTC+2.
    
    The default defaultOffset is Duration zero so that Squeak will have fast,
    globalized Dates out of the box.  Globalized Dates are common for applications.
    
    Legacy localized Dates can be obtained by evaluating "Date localize" so that,
    when an offset is not specified or otherwise involved in the input, the local
    offset will be used.
    
    Name: Kernel-cmm.671
    Author: cmm
    Time: 10 February 2012, 4:58:49.106 pm
    UUID: 9c0e18ac-1c8f-4ae6-b39e-d487720e8580
    Ancestors: Kernel-cmm.670
    
    Decided against the localized vs. globalized mode.  Timespans created in
    the context of an offset will start in that offset.  When no context is
    available, the defaultOffset for Timespans must be zero.  For example,
    two ways to make a Date for today:
    	Date today.  'start is midnight at offset zero.  Will compare successfully
    	to other Date today results.'
    	DateAndTime now asDate.  'In this case, the start is midnight of the local
    	time-zone.  It can only compare equally to Dates of its time-zone.'


Dave



More information about the Squeak-dev mailing list