=== Top of the Swiki === Attachments ===

TimeZone

This 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 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. 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.




Files:



What is included in the change set:
  1. Class PointInTime, an abstract representation of time independent of its representation in time zones (or in local Smalltalk systems).
  2. A time zone class hierarchy beginning with class LocalTimeTransform (this name is chosen to avoid conflicts with class TimeZine in VisualWorks, which already provides limited time zone support in a class of this name). Subclasses include

  3. 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).
  4. 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.



What to do:

  1. 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.
  2. Load the change set, then try the class examples in TimeZoneDatabase. The results you see will be relative to the time zone for Detroit, Michigan, USA.
  3. Set your default time zone with "TimeZoneDatabase systemDatabase defaultLocation: 'my-preferred-timezone-name'". You may need to get a more complete set of time zone files first (see below).
  4. 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:
  1. 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.
  2. 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
    ftp://ftp.cdrom.com/pub/linux/slackware-current/slakware/a1/zoneinfo.tgz
  3. 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.
  4. 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.
  5. 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 lewis@mail.msen.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 lewis@mail.msen.com