TimeZoneDatabase V1.2.2 Integration of the time zone database with Squeak Kernel-Chronology.
Version 1.2.2 adds class TimeZoneProxy, which provides TimeZone protocol for the local time zone transform in a TimeZoneDatabase. This permits methods such as DateAndTime class>>now and Time class>>now to obtain the correct time zone offset for any PointInTime, with compensation for daylight savings time and other peculiarities.
Rather than relying on a static definition of the time zone, expressions such as 'DateAndTime now' and 'Time now' will perform a dynamic lookup into the time zone database to determine the time zone offset. When daylight savings time takes effect, the time zone database will automatically compensate for the change.
Also, time zone offsets can now be expressed as Durations, as in:
TimeZoneDatabase systemDatabase durationFrom: 'America/Detroit' to: 'Canada/Newfoundland' ==> -0:01:30:00
Here is how to load a time zone database and set the default time zone on a Squeak image running on a typical Linux box:
1) Build a system database from files in the /usr/share/zoneinfo directory (a typical location for a Unix/Linux system).
TimeZoneDatabase buildSystemDatabaseForSqueak
2) Look for a suitable time zone to use. For example, if you live in Detroit, Michigan in the USA, you can find several valid time zone entries for Detroit by evaluating the following expression:
TimeZoneDatabase systemDatabase grepFor: 'Detroit'
3) Select a time zone to use as your default. For example, if you have decided to use 'America/Detroit', tell the database that this should be the default:
TimeZoneDatabase systemDatabase defaultLocation: 'America/Detroit'
4) Now tell Squeak to use this as its dynamic time zone setting.
TimeZoneProxy setDynamicLocalTransform: TimeZoneDatabase systemDatabase defaultTimeZone abbreviation: 'EST'
- Dave
I doubt that anybody is really worried about this, but just in case, when I posted the last update for TimeZoneDatabase, I claimed:
On Mon, Sep 20, 2004 at 10:26:07PM -0400, David T. Lewis wrote:
TimeZoneDatabase V1.2.2 Integration of the time zone database with Squeak Kernel-Chronology.
<snip>
Rather than relying on a static definition of the time zone, expressions such as 'DateAndTime now' and 'Time now' will perform a dynamic lookup into the time zone database to determine the time zone offset. When daylight savings time takes effect, the time zone database will automatically compensate for the change.
This is *not* correct. The conversions to and from Squeak DateAndTime are still not right when the transition takes place. In fact, I'm not sure that it's even possible to get this right with the current Squeak seconds clock (although I'm trying to think of a way).
Anyway, just in case anybody is relying on the TimeZoneDatabase conversions to do a correction for DST this weekend, be aware that you will get some incorrect conversion results on the evening of the DST transition.
Dave
squeak-dev@lists.squeakfoundation.org