Re-entrant, any-zone mktime()-equivalent?

Paul Eggert eggert at twinsun.com
Thu Nov 16 02:35:54 UTC 2000


> From: Jonathan Lennox <lennox at cs.columbia.edu>
> Date: Wed, 15 Nov 2000 17:41:18 -0500 (EST)

> Has anyone ever developed patches for tzcode to support a function that is
> the equivalent of timelocal()/mktime() and timegm() for arbitrary time zones?

Not that I know of.  The subject has come up more than once, but
nobody has done it as far as I know.

There is some Java code to do it: see 
<http://www.bmsi.com/java/ZoneInfo.java>.

You might also consider starting from the GNU C library code base.
There is a serious (i.e. it will probably be implemented soon)
proposal to do thread-safe locales with glibc in
<http://www.cygnus.com/~drepper/tllocale.ps.bz2>.
The same basic idea applies to time zones.
The glibc maintainer might buy back changes along these lines.


> <http://www.cs.columbia.edu/~lennox/draft-ietf-iptel-cpl-04.txt>.)

>From the tz list's point of view, Appendix A of that draft is perhaps
the most interesting one.  But frankly I couldn't follow it -- I have
a vague impression of what it's doing, but I couldn't make heads or
tails of it really, even though I read the earlier part of the RFC.
Some examples would help immensely.

I did notice this point:

        1.   Compute the time of the call, in the timezone of the time
             switch.  (No step after this needs to consider time zones
             -- all calculations are done using continuously-running
             standard Gregorian time.)

Suppose the current time zone is America/Los_Angeles, the time of the
call is 2000-04-02 01:30 -0800 (PST), and you have a two-hour time
slot.  (As I don't follow your terminology, I'm using informal terms
like "time slot".)  Since you use standard Gregorian time, I guess
you'll say that 2000-04-02 03:45 -0700 falls within the two-hour time
slot.  But 03:45 actually is only 1 hour and 15 minutes after the time
of the call, due to a DST change.  Is that what the user wants?

As an extreme case, consider Pacific/Kiritimati.  In that time zone
there is no day 1995-01-01, as they moved the clock 24 hours ahead at
midnight.  What will Algorithm A do with that case?  There are also
cases of clocks moving backwards 24 hours.

It might be helpful for you to supply examples that cover cases like
these.



More information about the tz mailing list