How do you generate POSIX time zone strings?
eggert at twinsun.com
Thu Mar 20 02:28:41 UTC 1997
Date: Wed, 19 Mar 1997 13:19:11 -0800 (PST)
From: Tony Glenning <tony at hape.Eng.Sun.COM>
For example, if this function were run on machine which has TZ set
to US/Pacific in 1997 it would generate:
First, perhaps you could explain a little why you want to do this,
since you lose information when you generate Posix strings from
Second, assuming you want to do this sort of thing, why would you want
to generate [*]? It's better to generate the following instead:
since [**] will work in years other than the current year. [**] isn't
as good as US/Pacific, but it's better than [*].
Here's how to generate [**] without parsing the zoneinfo files. Run
GNU Emacs, load-library cal-dst, and invoke (calendar-current-time-zone).
If TZ is US/Pacific, it should return
(-480 60 "PST" "PDT"
(calendar-nth-named-day 1 0 4 year)
(calendar-nth-named-day -1 0 10 year)
and it's easy to generate [**] from this value.
If you can't use GNU Emacs in your application, look at cal-dst's
source code for ideas about how to do it. GNU Emacs doesn't parse the
zoneinfo files; it just uses ANSI C localtime and gmtime like a good
More information about the tz