<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Thank you Paul and Zefram.</p>
    <p>Well my bad i missed to update the code with seconds while
      calling localtime.</p>
    <p>Even after that things didn't work for me.</p>
    <p><u>Code</u></p>
    <p> cat test_tz_simple.c <br>
      <font size="-1" face="Courier New, Courier, monospace">#include
        &lt;stdlib.h&gt;<br>
        #include &lt;string.h&gt;<br>
        #include &lt;time.h&gt;<br>
        #include &lt;syslog.h&gt;<br>
        <br>
        #include &lt;sys/time.h&gt; /* clude defn. of gettimeofday */<br>
        #include &lt;sys/types.h&gt;<br>
        <br>
        <br>
        int main()<br>
        {<br>
        u_int64_t time = 0;<br>
        struct timeval tv;<br>
        struct tm *tm;<br>
        int gmtoff, gmtoff_hr, gmtoff_min;<br>
        char *gmtoff_sign;<br>
        <br>
        if ( gettimeofday(&amp;tv, NULL) == 0)<br>
        {<br>
             time = (long long) tv.tv_sec;<br>
        <br>
        }<br>
        <br>
        <b>tm = localtime(&amp;tv.tv_sec);</b><br>
        printf ("epoch:%lld, %lld-%02d-%02d %02d:%02d:%02d gmtoff: %ld,
        TZ: %s\n",<br>
              time, tm-&gt;tm_year + 1900LL, tm-&gt;tm_mon + 1,
        tm-&gt;tm_mday,<br>
              tm-&gt;tm_hour, tm-&gt;tm_min, tm-&gt;tm_sec,<br>
              tm-&gt;tm_gmtoff, tm-&gt;tm_zone);<br>
        <br>
        if ( tm-&gt;tm_gmtoff &lt; 0 )<br>
            {<br>
                gmtoff = (0 - tm-&gt;tm_gmtoff );<br>
                gmtoff_sign = "-";<br>
            }<br>
            else<br>
            {<br>
                gmtoff = tm-&gt;tm_gmtoff;<br>
                gmtoff_sign = "+";<br>
            }<br>
        gmtoff_hr = gmtoff/3600;<br>
        gmtoff_min = gmtoff/60 - gmtoff_hr*60;<br>
        <br>
        printf("Time: %04d-%02d-%02d %02d:%02d:%02d.%03d %s%02d%02d \n",<br>
                                (tm-&gt;tm_year + 1900),
        tm-&gt;tm_mon+1, tm-&gt;tm_mday,<br>
                                tm-&gt;tm_hour, tm-&gt;tm_min,
        tm-&gt;tm_sec, time,<br>
                                gmtoff_sign, gmtoff_hr, gmtoff_min);<br>
        <br>
        } <br>
      </font></p>
    <p><br>
      <font size="-1" face="Courier New, Courier, monospace"></font><br>
         <br>
    </p>
    <p>Regarding setting TZ variable , we use customized linux platform.
      The way time zone is set is as follows</p>
    <p><font size="-1" face="Courier New, Courier, monospace">$ cat
        /etc/sysconfig/clock <br>
        UTC=true<br>
        ARC=false<br>
        ZONE=Asia/Manila</font></p>
    <p><font size="-1" face="Courier New, Courier, monospace">$ls -ltr
        /etc/localtime <br>
        lrwxrwxrwx 1 root root 31 Oct 26 12:31 /etc/localtime -&gt;
        /usr/share/zoneinfo/Asia/Manila</font><br>
    </p>
    <p>I tried export TZ=Asia/Manila before running a.out. But no luck.</p>
    <p>surprisingly, when i copy back 2016g version of tzdb binary,
      a.out gives correct result.</p>
    <p><font size="-1" face="Courier New, Courier, monospace">$ cksum
        /usr/share/zoneinfo/Asia/Manila_2016 <br>
        2614106258 319 /usr/share/zoneinfo/Asia/Manila_2016</font></p>
    <p><br>
      <u>Output with 2016g tzdb </u><br>
    </p>
    <p><font size="-1" face="Courier New, Courier, monospace">$ ./a.out
        <br>
        epoch:1509609002, 2017-11-02 15:50:02 gmtoff: 28800, TZ: PHT<br>
        Time: 2017-11-02 15:50:02.1509609002 +0800 <br>
        $ <br>
      </font></p>
    <p><font size="-1" face="Courier New, Courier, monospace">$ cksum
        /usr/share/zoneinfo/Asia/Manila_2017  <br>
        2995436782 311 /usr/share/zoneinfo/Asia/Manila_2017</font></p>
    <p><br>
      <u>Output with 2017a tzdb </u></p>
    <p><font size="-1" face="Courier New, Courier, monospace">$./a.out</font>
    </p>
    <p><font size="-1" face="Courier New, Courier, monospace">epoch:1509608903,
        2017-11-02 07:48:23 gmtoff: 0, TZ: <br>
        Time: 2017-11-02 07:48:23.1509608903 +0000 </font></p>
    In fact recompiling 2017 tzdb  replacing <font color="#d04437"><b>+08/+09
      </b><font color="#000000">by PH%sT for last row results in correct
        output.<br>
        <br>
        Please advice. <br>
        <br>
        Thanks &amp; Regards,<br>
        Arati<br>
        <br>
      </font></font><br>
    <div class="moz-cite-prefix">On Thursday 02 November 2017 03:01 AM,
      Paul Eggert wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:a455ffe1-80f8-9d70-8d5c-9e573ea2666d@cs.ucla.edu">On
      11/01/2017 01:12 PM, Zefram wrote:
      <br>
      <blockquote type="cite">localtime() operates on a time_t, the
        value of
        <br>
        which you need to get from time() or from the .tv_sec part of
        what you
        <br>
        get from gettimeofday().  Instead you've taken a correct .tv_sec
        and
        <br>
        multiplied it by 1000.  Instead of asking about November 2017
        you've
        <br>
        asked about October 49804.  A zero offset is still not what the
        tzdb
        <br>
        projects for 49804, but localtime() can be forgiven for giving
        up.
        <br>
      </blockquote>
      <br>
      Although that is indeed a problem with the program, I suspect that
      there's some other issue as well. I just now compiled and ran the
      following simpler variant of the program on Fedora 26 x86-64
      (64-bit long and time_t), linked to the current tzdb code and
      data:
      <br>
      <br>
      #include &lt;time.h&gt;
      <br>
      #include &lt;stdio.h&gt;
      <br>
      int
      <br>
      main (void)
      <br>
      {
      <br>
        time_t time = 1509521131510;
      <br>
        long long ltime = time;
      <br>
        struct tm *tm = localtime (&amp;time);
      <br>
        printf ("epoch:%lld, %lld-%02d-%02d %02d:%02d:%02d gmtoff: %ld,
      TZ: %s\n",
      <br>
            ltime, tm-&gt;tm_year + 1900LL, tm-&gt;tm_mon + 1,
      tm-&gt;tm_mday,
      <br>
            tm-&gt;tm_hour, tm-&gt;tm_min, tm-&gt;tm_sec,
      <br>
            tm-&gt;tm_gmtoff, tm-&gt;tm_zone);
      <br>
        return 0;
      <br>
      }
      <br>
      <br>
      With the TZ environment variable set to "Asia/Manila", it outputs
      the expected value:
      <br>
      <br>
      epoch:1509521131510, 49804-10-27 17:25:10 gmtoff: 28800, TZ: +08
      <br>
      <br>
      With the TZ environment variable unset, it outputs:
      <br>
      <br>
      epoch:1509521131510, 49804-10-27 09:25:10 gmtoff: 0, TZ: GMT
      <br>
      <br>
      which are the reported symptoms. But the latter output is also
      correct, since the default wall-clock time, if you just install
      tzdb without any special configuration and do not set TZ, is the
      same as if you had set TZ="GMT0".
      <br>
      <br>
      <br>
    </blockquote>
    <br>
  <br><div>
<font face="Helvetica">
<hr>
<br> 
<p><b><span style="font-size:12.0pt;font-family:&quot;Calibri&quot;,sans-serif">Learn how to protect users, data, and applications with security engineered for the public cloud by Barracuda. <a href="http://barracuda.com/">http://barracuda.com</a></span></b></p>
<br> 
</div>
<div>
<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><b>DISCLAIMER:</b> This e-mail and any attachments to it contain confidential and proprietary material of Barracuda, its affiliates or agents, and is solely for the use of the intended recipient. Any review, use, disclosure, distribution or copying of this transmittal is prohibited except by or on behalf of the intended recipient. If you have received this transmittal in error, please notify the sender and destroy this e-mail and any attachments and all copies, whether electronic or printed.</span></p>
<br>
<hr>
</font>
</div>
&nbsp;&nbsp;&shy;&shy;&nbsp;&nbsp;</body>
</html>