[ENH][GOODIE] Time Zone Support for Squeak

David T. Lewis lewis at mail.msen.com
Wed Dec 22 16:18:47 UTC 1999


--HlL+5n6rz5pIUxbD
Content-Type: text/plain; charset=us-ascii



As the end of the millenium nears, I am moved to attempt the creation of a
work of enduring value and social import: A Squeak utility for scheduling
New Years Eve celebrations in synchronization with the coming of the year
2000 in every known time zone around the world. Particularly ambitious
revelers may elect to hoist a cup twice for each geographic zone, once for
each time zone as represented casually on most computers, and once again 22
seconds later in recognition of the influence of leap seconds on local time
observances.

Of possible incidental interest to more sober observers of the millenial
transition, I am including a time zone database which can be initialized
from data in tzfile formatted time zone files as found on many newer Unix
systems, especially Linux and FreeBSD. The database answers UTC offsets for
each time zone at any point in time, and includes leap second compensation
for time zones whose tzfile data includes a leap second table.

After loading the change set and initializing from the time zone files on
your computer (or from a small set of representative files which I have
provided as examples), inspect "TimeZoneDatabase partyTimes" to obtain the
essential revelry schedule.

Happy New Year!

  ------------------------------------------------------------------------

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 TimeZone class hierarchy. Subclasses include
        o NaiveTimeZone, which behaves like a Smalltalk system with no time
          zone rules
        o OSTimeZone, which uses a plugin to ask the underlying operating
          system about time zone offsets (useful only on Unix based systems)
        o 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.

  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. Unzip the attached ZIP archive in your Squeak directory. This will
     give you the TimeZone.21Dec1124am.cs change set, a handy cpzones
     shell script for copying timezone files from Unix boxes, and a
     small set of representative time zone data files to get you started.
  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.

  ------------------------------------------------------------------------

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 a real computer 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 with a real computer and ask for a copy of the files in
     the /usr/share/zoneinfo directory. If your computer is a Mac or Windows
     machine, try to convince your friend to copy the time zone files with
     a naming convention which your computer can handle (that is, no
     directories with "/" in the path names). The cpzones Unix 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.


--HlL+5n6rz5pIUxbD
Content-Type: text/plain; name="TimeZone.zip"
 ; x-mac-type="705A4950"
 ; x-mac-creator="705A4950"
Content-Disposition: attachment; filename="TimeZone.zip"
Content-Transfer-Encoding: imap_stub

0,2595,2,49424,0,

--HlL+5n6rz5pIUxbD--





More information about the Squeak-dev mailing list