title: Time zone conversion C API on Linux, anyone?
body: <p>I'm looking for something that I presumed would be very simple - given local Unix time in a specific time zone (specified as a string, e.g., "America/New_York" - note that's <em>not</em> my local time), get the corresponding time value in GMT. I.e., something along the lines of</p>
  
  <pre><code>time_t get_gmt_time(time_t local_time,
                      const char* time_zone);
  </code></pre>
  
  <p>As deceptively simple as it sounds, the closest I could find was the following code snippet from timegm's man page:</p>
  
  <pre><code>       #include &lt;time.h&gt;
         #include &lt;stdlib.h&gt;
  
         time_t
         my_timegm(struct tm *tm)
         {
             time_t ret;
             char *tz;
  
             tz = getenv("TZ");
             setenv("TZ", "", 1);
             tzset();
             ret = mktime(tm);
             if (tz)
                 setenv("TZ", tz, 1);
             else
                 unsetenv("TZ");
             tzset();
             return ret;
         } 
  </code></pre>
  
  <p>There gotta be a better way than this belligerently not thread-safe abomination, right? Right??</p>