The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Got Time?

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Got Time? Posted: Dec 16, 2004 2:31 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Got Time?
Feed Title: Travis Griggs - Blog
Feed URL: http://www.cincomsmalltalk.com/rssBlog/travis-rss.xml
Feed Description: This TAG Line is Extra
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Travis Griggs - Blog

Advertisement
After having played around with this for awhile, I think I've hit upon a solution, that at least works for us. OSTimeZone (a package in the Open Repository used by at least Bottom Feeder and the guys at MetaCase) had what appeared to be two strategies for dealing with getting at OS localized time values:

  1. A parallel set of APIs for getting at the os time. Methods like Timestamp>>osNow.
  2. A method for attempting to derive a VW timezone that is similiar to the OS one, and then setting that as the current.

Working with this stuff... is an event horizon in and of itself. I was nearly sucked into the black hole known as trying to model this thing that we think is simple and constant. Einstein would be truly impressed with how relative we have made time. Benjamin Franklin used to be a hero; hereafter all ideas that came after his little "shocking kite" experience are suspect (like Daylight Savings Time).

Having worked with strategy (1), we added osNow to Time and osToday to Date. To finish it completely, to the best of my knowledge, one would need to provide alternate versions of Filename>>getDates which produced local times from the OS's perspective. Having to hunt down and change all references to the old APIs to the new one, and contemplating how different stat is on every platform, etc, I threw the towel in on this one.

My problem with (2) is... I'm not sure I trust it. No offense is meant to its authors. I'm quite sure my sanity would not have persevered to get as much as has been done. But it does state that it doesn't do DST on *nix platforms. That's a show stopper for us because we run weeks on end under Linux, across DST switches. After having parsed a posix zoneinfo file, I saw all kinds of parameters, that the VW timezone model is is no way equipped to deal with. No clue how complex the Windows model might be. There was also the hardcoded reference to the year 1998 in this code that gave me the jitters.

Having played with these, and talked to various people about it in different channels, I've realized there are two general goals of people working with TimeZones:

  1. To be able to have a rich time model, do time computations across time zones, etc.
  2. To do what other applications on your desktop do, show the time relative to the timezone specified for your computer with the desktop tools, without having to do anything special. And preferrably, if the OS specified time zone changes, to not have to restart the application.

My immediate needs have been for (2). To make it happen, I added a Third strategy to the OSTimeZone package. A TimeZone subclass is created to be a bridge to the OS's conversion routines. By making it a subclass of TimeZone, it remains polymorphic with other TimeZone instances. The key conversion APIs to implement are convertGMT:do: and convertToGMT:do:. It forwards these onto the various OSSystemSupport classes. To use it, you just create an instance of this OSSystemSupportTimeZone and make it the reference/default TimeZone. There's a handy use method on the class side that does this.

So far, I've been pretty pleased with this. It seems to compute a Timestamp now just fine. Because it's at this core level, even a Filename getTimes is correct. Whatever the OS is set to (did you know there are two Arctic time zones?), it's always that. It can be preloaded into the image, so that ANY times produced at startup time will be correctly localized (iow, doesn't have to wait for a "sync" step to get it right). Even cooler, on most platforms, if you change the OS's timezone while it's running, VW just goes right along with it. I've tested it on a Windows box, a MacOSX box, and Debian Linux box. Debian Linux is the one platform where changing it while VisualWorks is running makes no change, you have to restart it. This however is a glibc (mis)feature. All Linux applications have this problem unless they jump through an involved set of hurdles. I suspect that an environment that uses TZ environment variable to specify the timezone, rather than defaulting to the /etc/localtime symlink, might actually even track changes.

Read: Got Time?

Topic: Free PDF book 'Essential Skills for Agile Development' Previous Topic   Next Topic Topic: Koramis SpecSheet Web app

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use