title: How to programatically convert a time from one timezone to another in C?
body: <p>The info pages for the GNU <code>date</code> command contains this example:</p>
  
  <blockquote>
    <p>For example, with the GNU <code>date</code>
    command you can answer the question
    "What time is it in New York when a
    Paris clock shows 6:30am on October
    31, 2004?" by using a date beginning
    with `TZ="Europe/Paris"' as shown in
    the following shell transcript:</p>
  
  <pre><code> $ export TZ="America/New_York"
   $ date --date='TZ="Europe/Paris" 2004-10-31 06:30'
   Sun Oct 31 01:30:00 EDT 2004
  </code></pre>
    
    <p>In this example, the '--date'
    operand begins with its own 'TZ'
    setting, so the rest of that operand
    is processed according to
    'Europe/Paris' rules, treating the
    string <code>2004-10-31 06:30</code> as if it
    were in Paris.  However, since the
    output of the <code>date</code> command is
    processed according to the overall
    time zone rules, it uses New York
    time.  (Paris was normally six hours
    ahead of New York in 2004, but this
    example refers to a brief Halloween
    period when the gap was five hours.)</p>
  </blockquote>
  
  <p>I am trying to accomplish essentially the same thing programatically in C without calling the <code>date</code> program millions of times.  Basically I am looking for a way to take an arbitrary date and time in one timezone and convert it to the equivalent date and time in another timezone either directly or via conversion to and from UTC.  I don't care about the formats of the input and output time as long as I can manipulate them using standard functions (<code>strftime</code>/<code>strptime</code>/<code>mktime</code>/etc).</p>
  
  <p>The <code>date</code> program appears to accomplish this using complex routines internal to the <code>coreutils</code> package, I am looking for a way to do this in C using either standard POSIX/Linux routines or an external library.  I looked at <a href="http://en.wikipedia.org/wiki/Zoneinfo" rel="noreferrer">zoneinfo</a> quite a bit which seemed promising but I cannot find any libraries to do anything useful with it.</p>