Chronos is one of the many Smalltalk-related blogs syndicated on Planet Smalltalk
χρόνος

Discussion of the Essence# programming language, and related issues and technologies.

Blog Timezone: America/Los_Angeles [Winter: -0800 hhmm | Summer: -0700 hhmm] 
Your local time:  
Showing posts with label VisualWorks. Show all posts
Showing posts with label VisualWorks. Show all posts

2007-04-29

About the version of Chronos distributed with VW 7.5...

VisualWorks 7.5 was released (finally!) a few days ago. For the first time, the Chronos Date/Time Library is included as a contributed component.

However, I would like to make everyone aware of the following points:


  • The version of Chronos that is on the CD (or that is available from the download page) is an ancient version from early January 2006 (more than a year ago.)

  • No Chronos parcels are included. Only the "Chronos.st" and "Chronos-Utilities.st" files are present (because back in January 2006, I wasn't distributing parcel files for Chronos.) I've been including parcels in the VisualWorks version of the Chronos download archive since March 2006.

I really recommend that, instead of using the version of Chronos that comes with VW 7.5, you either download the latest version of Chronos (Chronos Version B1.196), or else get the latest released version from the Cincom Public Store.


2007-03-12

2007 North American DST Changes: Resources & References (2)

Due to the changes at Planet Smalltalk, which have invalidated all URLs to old articles, and due to the fact that Google searches are still preferentially returning results to now-invalid URLs at Planet Smalltalk, I am republishing the following information:


The Chronos Date/Time Library has had the correct DST rules for North America since 2005-08-22 (a year and a half ago.)


2007-02-16

Handling various text file line-end conventions in VW

Martin Kobetic has posted an excellent tutorial on handling different text file line-end conventions in VisualWorks.

The Passport inter-Smalltalk portability library (on which the Chronos Date/Time Library depends) also provides a solution to the same problem:


  • UtilityFunction nextLineFrom: aStream

  • UtilityFunction skipToNextLineOf: aStream

Both of the above functions will work with any of the three text file line-end conventions currently encountered in the wild: CRLF (Windows,) LF (Unix/Linix/MacOS X) and CR (classic MacOS.)

Passport does not provide any support for writing text files using different line-end conventions, for two reasons:

  1. The external WriteStreams provided by most Smalltalk implementations will already convert CR to the host platform's line-end convention.

  2. Given the ability to read text files correctly, regardless of line-end convetion, there is not as much need to be able to write files with any particular line-end convention.

Chronos uses both of the above Passport functions in order to read time zone and other information from text files stored in the Chronos Time Zone Repository. Using those two Passport functions not only provides Chronos with inter-Smalltalk portability, it also means that a single version of the Chronos Time Zone Repository can be used on all host platforms, even when the text files were generated on a different operating system.


2007-02-08

The times they are a-changing...

The last time the rules for entering and leaving Daylight Saving Time changed in North America was 1987. That was a very different world than we have today. It was significantly less automated, significantly less computerized and significantly less dependent on computers and software for accomplishing mission critical tasks.

So, on an upcoming fateful day in March 2007, when legal, civil time in North America's "Eastern Time Zone" jumps in an instant from 2007-03-11T01:59:59.99999999...-05:00 to 2007-03-11T03:00:00-04:00, what will happen? How many computer systems, and devices using embedded computer systems, will fail to recognize that civil time is suddenly an hour later than it had been? And what consequences are likely to ensue?

I strongly suspect (to put it mildly) that the number of systems that won't have the correct civil time will be decidedly non-trivial. But the likely consequences of that timekeeping failure are much harder to guess. One likely result will be users complaining about 1-hour time-of-day discrepancies. The most likely cause of serious malfunctions will be situations where two or more computer systems colloborate together in such a way that clock synchronization matters, with some (but not all) of them still using the old time zone rules for North America.

The best way to handle the problems that might arise due to your computers using the wrong time zone rules is to make sure all your computers know the new rules. If you do nothing, it's highly likely that your computers won't know anything about it (and that's true from Mainframes to PDAs, especially including computers that use Unix or Windows.)

Here are some resources with helpful information about updating the time zone rules for computers of various types:


But updating the operating system may not be sufficient. For reasons I won't go into here, there are many applications that don't rely on the OS to tell them what the time zone rules happen to be. One prominent example is Java. Another that may be of some interest to my intended audience on this blog (the community of Smalltalk programmers,) would be one of the most widely used Smalltalk variants: VisualWorks.

For information about updating Java applications with the new time zone rules, refer to the following:
Smalltalkers who use the Chronos Date/Time Library in their Smalltalk applications, and who obtained any version of the Chronos Time Zone Repository after late-August 2005 (a year and half ago!) already have the new time zone rules for North America. This is because the new rules were known as soon as Congress passed the Energy Policy Act of 2005 (in the Summer of 2005,) and also because the Chronos time zone rule sets are able to represent not only the rules for the current year, but also rules for other either past or future years that differ from those currently in effect.

As for those Smalltalkers who don't use Chronos in their applications, the situation is as follows:

VisualWorks: The time zone rules must be updated. My earlier blog post, VW: 2007 TimeZone settings for North America, explains how to do so.

Squeak: Those using the "out-of-the-box" Chronology classes don't need to do anything. But that's not because the Chronology classes know all about time zones, but rather because they don't. For many situations, there is no need for the Chronology classes to know anything about time zones. Squeak relies on the operating system to tell it what the local time currently is. That's a very simple approach...which stops working as soon as you need to do any of the following things:
  • Convert a date/time from some other time zone into your local time (because you don't know what your offset from Universal Time happens to be, and may also not know the offset of the other time zone.)
  • Convert a local date/time to some other time zone (for the same reasons as above.)
  • Correctly compute the amount of physical, elapsed time between two points in time (because you won't know whether the time zone offsets of the two points in time were the same, since there may have been one or more intervening DST transitions; or worse, the two points in time may not even have been intended to represent time in the same time zone.)
  • Correctly compute the point in time that results when adding a duration to a point in time (again, because you won't know whether the offset will be the same, since the offset may be different even a fraction of a second earlier or later.)

But those using Squeak have two other options. One is Chronos, which has already been discussed. The other is the David T. Lewis' TimeZoneDatabase (which functions in a way very similar to Chronos, at least as far as time zones are concerned.) Just like Chronos, the TimeZoneDatabase relies on an external repository of time zone rules--and both use the Olson Time Zone Database as the source of those rules. On Unix-based hosts, the TimeZoneDatabase can be configured to use the same binary "tzfiles" as Unix itself uses, at the same disk location--which means that updating the operating system's time zone rules also updates the TimeZoneDatabase. But on non-Unix based systems, the "tzfiles" must be updated separately.

Dolphin Smalltalk: Dolphin uses Windows system calls to get the current local time. Although Dolphin very helpfully provides the ability to get time zone information from the Windows Registry, its native TimeStamp class doesn't use that capability to provide time-zone-aware date/time behavior. Chronos is also available for Dolphin.

Most other Smalltalk systems are essentially similar to either Squeak or Dolphin, as far as time zone functionality is concerned.

But all this raises a very good question: Why are time zones such a hard problem?


2007-01-17

VW: 2007 TimeZone settings for North America

Those of you who reside in North America and use VisualWorks (or ship VW-hosted applications to North America,) but aren't using Chronos, need to update your time zone rules. The rules for the North American time zones currently in all shipped versions of VisualWorks are not correct for 2007 and later, since the US Congress changed start and end rules for daylight saving time in the United States, effective as of 2007.

The old rules (which had been in effect since 1987) were that the transition from standard time to daylight saving time happened on the first Sunday of April, and the transition from daylight saving time back to standard time happened on the last Sunday of October (both at 2am local time.) Under the new rules, standard time transitions to daylight saving time on the second Sunday of March, and transitions back to standard time on the first Sunday of November.

One way to make the necessary change is to evaluate the following "do it" (which is correct for Pacific Time):

TimeZone 
setDefaultTimeZone:
(TimeZone
timeDifference: -8 "Pacific Time"
DST: 1 at: 2
from: 73 "Second Sunday of March"
to: 311 "First Sunday of November"
startDay: #Sunday).

Instead of the "timeDifference: -8" which is correct for Pacific Time, Mountain Time has a time difference of -7 hours, Central Time has a time difference of -6 hours, and Eastern Time has a time difference of -5 hours. Arizona is the big exception, since it does not observe daylight saving time (but Navajo reservations in Arizona do observe DST!) The Arizona rules haven't changed.

Another way to get the correct rules is to install the TimeZone-External Repository-Olson TZDB package, which can be downloaded from the Chronos web site, or simply by clicking on the following link: TimeZone-External Repository-Olson TZDB (read and follow the installation instructions.)

Once the TimeZone-External Repository-Olson TZDB package has been installed (according to the instructions,) evaluating one of the following "do its" will update "Core.TimeZone default" with the correct rules:

(TimeZone at: 'America/New_York') beReference
(TimeZone at: 'America/Indiana/Indianapolis') beReference
(TimeZone at: 'America/Chicago') beReference
(TimeZone at: 'America/Denver') beReference
(TimeZone at: 'America/Boise') beReference
(TimeZone at: 'America/Phoenix') beReference
(TimeZone at: 'America/Los_Angeles') beReference
(TimeZone at: 'America/Nome') beReference
(TimeZone at: 'America/Adak') beReference
(TimeZone at: 'Pacific/Honolulu') beReference

Yet another way to get the correct time zone rules is to install Chronos.


2006-01-10

VW 7.4 Synchronizes Its Clock

Cincom didn't publicize it, but VW 7.4 includes a fix that may be quite useful in some situations.

In previsous versions, once an image had started running, the count of microseconds returned by primitive 351 (or the count of milliseconds returned by primitive 350, in versions of VW prior to VW7) was unaffected by any adjustments made to the host platform's system clock. So, if an NTP service was running that kept the host system's clock synchronized with a time server, any running VW image would receive no benefit. Clock adjustments from any source (including the user) were invisible to a running VW image.

Most computer clocks are not all that accurate. They can diverge from accurate time by minutes per month. Such inaccuracy may be acceptable to many, but to some it is not. There are technical, scientific, legal and even business use cases that must have a clock with much greater accuracy. Having "legally traceable time" may be the difference between winning and losing a lawsuit.

But as of VW 7.4, VisualWorks will be useable in use cases where time must be accurately kept within subsecond tolerances over long periods of time, without requiring an expensive, non-standard clock device.