FW: accessing DST rules at runtime
-----Original Message----- From: Dave Hackenyos [SMTP:hackenyo@roguewave.com] Sent: Friday, April 16, 1999 8:12 PM To: ado@elsie.nci.nih.gov Subject: accessing DST rules at runtime Hello, I have been working on an implementation problem about which you may have some insight. I hope you don't mind a question or two. I am attempting to discover a way to query any (most) Operating Systems about what it may think the daylight rule is for the Timezone in which it thinks it is located. I wish to do this at runtime. I am aware that a call to tzset() will set a host of information, but only a few are available to the programmer (tzname, daylight, etc). I cannot find a way to get at the exact DST rule information even though the system is well aware of it during every call of localtime(). Your tar files at elsie.nci.nih.gov are full of info about the subject and several, if not all platforms of interest to me use it. Your localtime() function seems to know how to parse these binary zoneinfo files, but once again, I am unable to discern how to access the DST rule info for my own use. My question: Could you shed some light on how (given knowledge of the path to a particular OS's zoneinfo location) one could gleen the DST rule at runtime? I would be forever in your debt. Thanks for any help you could send my way, Dave Hackenyos hackenyo@roguewave.com (541)754-2976
From: Dave Hackenyos [SMTP:hackenyo@roguewave.com] Sent: Friday, April 16, 1999 8:12 PM I am attempting to discover a way to query any (most) Operating Systems about what it may think the daylight rule is for the Timezone in which it thinks it is located. The problem can't be solved in general, since governments change the rules periodically, and systems using the Olson implementation can record these changes. For example, the system might currently be configured to use American-style daylight-saving rules for timestamps before July 1, and European-style rules for timestamps thereafter. This sort of thing really does happen. If you want accuracy, the best method I know of is that of zdump.c in the tzcode distribution. zdump just probes ahead, one day at a time, until it discovers a UTC offset change; it then reports this change to the user. It makes no attempt to guess what the ``rules'' are, since there may not be any. For example, see Israel, where the government seems to decide the transition times each year separately and arbitrarily. If you really want a single set of rules, and are willing to give up some accuracy, then the best code that I know of is the code that Edward M. Reingold and I contributed to the GNU Emacs distribution; see the calendar-time-zone-daylight-rules function of lisp/calendar/cal-dst.el, which intuits the daylight saving rules from zdump-like probes into the future. I should warn you that it's pretty hairy going; among other things, the code works even in Iran, which determines DST transitions using a method based on the (non-Gregorian) calendar of Omar Khayyam.
participants (2)
-
Olson, Arthur David (NCI) -
Paul Eggert