timezone programming question: converting UTC to local time

I am looking for a way to convert a UTC time to the corresponding local time in any given timezone, not necessarily the

timezone that the process is running in. Something like localtime_r(const time_t *utc, const char *name_of_timezone,

struct tm *res) would do. It has to be MT-safe, so I can't just save TZ, change TZ to the desired timezone, call

localtime() and then restore TZ.

[418 byte] By [mxiong] at [2007-11-25 23:41:41]
# 1
were you ever able to get an answer?Also where would one find a list of the valid Timezone values such that one could present a list to be selected from?thanks,jsilver@unispherenetworks.com
jonjsilver at 2007-7-5 18:49:15 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 2

Except for the mapping of placename to timezone, I think most of your questions can be answered by the "ctime" manpage. You'll need a mutex to serialize access to these functions while the TZ is set to a particular value, and I recommend that you use the *_r variant of the calls.

An old, but useful book, "Advanced UNIX Programming" by Marc J. Rochkind, devotes several pages to times, dates, and timezones.

... Dave

mdfeather at 2007-7-5 18:49:15 > top of Java-index,Development Tools,Solaris and Linux Development Tools...