computing times in other zones without setting TZ

Paul Eggert eggert at twinsun.com
Wed Apr 8 00:56:47 UTC 1998


   From: 	Guenther Grau[SMTP:Guenther.Grau at bk.bosch.de]
   Sent: 	Tuesday, April 07, 1998 12:36 PM

   In my application I need to know, the time difference
   between any given time in any given timezone, and UTC. Is
   this possible to do WITHOUT changing the TZ environment
   variable?

Not without some hacking.

You could take the public domain tz code
<ftp://elsie.nci.nih.gov/pub/>, or the GNU C library code
<ftp://ftp.gnu.org/pub/gnu/glibc-2.0.6.tar.gz>, and make a truly
reentrant version of the localtime function, so that you can pass the
time zone rule as a separate argument to your modified version of
localtime.

If you do this, please send your improvements to the original authors;
you're not the first to have asked about this but nobody has
implemented it yet as far as I know.



More information about the tz mailing list