Last updated at 3:54 pm UTC on 17 April 2011
The latest versions of TimeZoneDatabase are now maintained on on SqueakSource at http://www.squeaksource.com/TimeZoneDatabase, and may be loaded from SqueakMap or from a Montecello browser.
License is MIT. Earlier versions were dual licensed under your choice of Squeak-L or MIT license.
Contributed by Dave Lewis.
TimeZoneDatabase is a time zone database for Smalltalk. It answers the number of seconds offset from UTC for any time zone at any point in time in the range of the database rule set, as well as the number of leap seconds for a point in time (for tzfiles that contain the leap second rules).
TimeZoneProxy provides a dynamic time zone to calculate DateAndTime at any point in time in any time zone. Dynamic corrections for daylight savings time and leap seconds are made according to the local time zone setting. Time zone rules are provided by TimeZoneDatabase. A TimeZoneDstTransitionWatcher detects "fall back" daylight savings time transitions, and maintains correct conversions from the Squeak seconds clock to absolute time.
A full time zone database requires access to tzfile data files, typically distributed with Unix (Linux) systems, and often located in the /usr/share/zoneinfo directory.
When TimeZoneDatabase is initially installed, the system time zone (DateAndTime class>>localTimeZone) is set to 'UTC' (no UTC offset, no daylight savings offset, no leap seconds). Here is how to set a new default time zone for Squeak:
1) 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 grepFor: 'Detroit'
2) Set a time zone to use as the system default. For example, if you have decided to use 'America/Detroit', tell Squeak to use this as its dynamic time zone setting:
TimeZone setLocal: 'America/Detroit'
Time zones with names that begin with "right" include the rules for leap second adjustments, while time zones with names beginning with "posix" will ignore leap seconds. You may need to experiment with your system to find which time zone settings best match your requirements. If in doubt, use a time zone that does not include leap second tables.
The time zone database can be rebuilt or updated by reloading from files in the /usr/share/zoneinfo directory (a typical location for a Unix/Linux system). If your system does not have these files available, they may be copied from another system or obtained on the internet.
If you want to stop using TimeZoneDatabase for your Squeak time zone settings and go back to a default TimeZone:
DateAndTime localTimeZone: TimeZone default
For an explanation of the Squeak seconds clock and how it relates to various representations of time, see the "documentation" method category in class PointInTime.
Download TimeZoneDatabaseV1-3-2-dtl.cs (27-June-2009).
Download TimeZoneDatabaseV1-2-5-dtl.cs.gz (22-Aug-2007). If you are updating an existing TimeZoneDatabase, you may prefer use this Montecello version Time-dtl.mcz.
Download TimeZoneDatabaseV1-2-4-dtl.cs.gz (17-Feb-2007).
Download TimeZoneDatabaseV1-2-3.sar (24-Nov-2004)
Download TimeZoneDatabaseV1-2-2.sar (20-Sept-2004)
This is a time zone database for Smalltalk which also now provides ISO8601 support for Time Date, and TimeStamp. It answers the number of seconds offset from UTC for any time zone at any point in time in the range of the database rule set, as well as the number of leap seconds for a point in time (for tzfiles which contain the leap second rules).
Time zone rules are loaded by reading compiled tzfile files from an external source. Compiled tzfiles files are commonly distributed with Unix and Linux systems.
A compiled tzfile is typically generated by the zic(1) compiler distributed as part of the public domain timezone database in the ~ftp/pub directory of elsie.nci.nih.gov FTP server, and commonly included in Linux and Unix distributions. Source code, documentation, and the full (human readable) rule file source is available from elsie.nci.nih.gov. The tzfile data must be obtained separately. If you have a Unix-like system, look in /usr/share/zoneinfo.
This package was written on a Squeak system and also runs on VisualWorks and Smalltalk/X. Some code is conditionally compiled to support platform variations.
The OSTimeZone class and TimePlugin class are provided for use on Squeak systems runing on Unix like operating systems. They are neither used nor required on other systems. Functionally, they provide a light weight subset of a TimeZoneDatabase. When running on VisualWorks or Smalltalk/X, the VwOSTimeZone and StxOSTimeZone classes provide similar access to time zone services on these platforms.
Update: ISO8601 Format support has been added. Useful info on ISO8601 can be found at http://www.cl.cam.ac.uk/~mgk25/iso-time.html
The update has added methods for reading and writing ISO formats to Time and Date. Time has also been extended for reading of timezone offsets of the format Z (Zulu time) or [+-]hh(:mm) to specify an offset from Z time. The TimeStamp class is the TimeStamp class provided as part of SqueakMap, but reimplemented to use PointInTime for its implementation.
TimeZoneDatabase now initializes when first accessed and prompts the user to select the current time zone. Once the time zone is set, all timezones except the selected one and Zulu are unloaded. Should one wish to change the timezone - simply evaluate TimeZoneDatabase systemDatabase defaultLocation: nil and then try to create a TimeStamp. The timezone data will reload, a menu displayed, and then unloaded again after the user makes a selection.
Released December 1999 and January 2000 OSProcess
ISO 8601 and other enhancements by Todd Blanchard December 2002
TimeZone V1.2.2 for Squeak 3.7 with ANSI support 20-Sept-2004 OSProcess
What is included in the change set:
- Class PointInTime, an abstract representation of time independent of its representation in time zones (or in local Smalltalk systems).
- A time zone class hierarchy beginning with class LocalTimeTransform (this name is chosen to avoid conflicts with class TimeZone in VisualWorks, which already provides limited time zone support in a class of this name). Subclasses include
- NaiveTimeZone, which behaves like a Smalltalk system with no time zone rules
- OSTimeZone, which uses a plugin to ask the underlying operating system about time zone offsets (useful only on Unix based systems)
- TimeZoneRuleSet, which represents a time zone in the time zone database, and knows how to create instances of itself by parsing compiled time zone files in tzfile(5) format, commonly found on newer Unix-like systems.
- TimeZoneDatabase, which maintains a dictionary of time zones, and answers UTC offsets and leap second offsets for its time zones at any point in time (a PointInTime).
- A plugin to support operating system queries for the OSTimeZone class. This is optional, and OSTimeZone attempts to default to sensible behavior in the absence of the plugin.
- Addional methods on Time and Date for reading and writing ISO formats.
- TimeStamp implemented in terms of PointInTime
What to do:
- Download the change set and example time zone files. Unzip the time zone files in your Squeak directory. This will give you some representative time zone files (copied from a Linux distribution and renamed so they will work on other kinds of computers). You may also want to download the cpzones script, which is useful for copying time zone files from a Unix system into files with names which will work on other systems.
- Load the change set.
- Edit the tzPrefixPath class method in TimeZoneDatabase to point to the system zoneinfo files on your system (you may need to download a set - see the comments for where to get them).
- Evaluate TimeStamp now in a workspace and select your timezone from the popup menu.
- You may need to get a more complete set of time zone files first (see below).
- Read the class documentation for more information. Try using the object explorer on your time zone database to get a better understanding of what it's doing. There are some class side example methods in class TimeZoneDatabase to get you started.
Here is how to get a complete set of time zone data files if you don't already have them on your computer:
- If you are using a Linux, FreeBSD, or other system with time zone files in the /usr/share/zoneinfo directory, you can execute the expression "TimeZoneDatabase buildSystemDatabase" to load a complete database of the world's time zones from your system database files.
- If your computer understands how to do gzip and tar, download a set of compiled time zone files from a Linux or FreeBSD distribution. For example, a full set of compiled time zone files, in the form of a gzipped tar archive, may be found at
- Convince someone with a web server running on some flavor of Unix to add a to the files in their web server's /usr/share/zoneinfo directory so that you can download them.
- Find a friend who uses Linux and ask for a copy of the files in the /usr/share/zoneinfo directory. If your computer is a Mac or Windows machine, copy the time zone files using a naming convention which your computer can handle (that is, no directories with "/" in the path names). The cpzones shell script will help your friend do this for you.
- The real source of all this time zone data is the ~ftp/pub directory of elsie.nci.nih.gov, which provides current time zone data, documentation, and source code for C language time zone utilities.
Copyright (C) 1999, 2000 David T. Lewis email@example.com
You may use, reproduce, make derivative works or distribute the software under the terms of either the Gnu Public License (http://www.gnu.org/copyleft/gpl.html) or the Squeak License (http://www.squeak.org/license.html), whichever you prefer. No other license terms are permitted without written consent of the author.
(Squeak question: Is GPL an appropriate way to release this? I want this to be freely available for any purpose on any flavor of Smalltalk, and GPL seemed like the best overall choice, given that I'm also putting out VisualWorks and Smalltalk/X versions. Pseudo-legal advice appreciated.)
GPL is decidedly non-Squeak friendly. The license conflicts with the Squeak license in such a way as to make it impossible for a user who incorporates the GPL'd software to further distribute the software. Instead, I suggest distributing it subject to the terms of the Squeak license. –Andrew C. Greenberg
Thanks for the advice. I have updated the license (see above) according to your suggestions. If the licensing causes any kind of problems for anybody, please let me know. My only objective is to keep it open source. – Dave Lewis firstname.lastname@example.org