<div dir="ltr"><div><div><div><div><div><div><div><div><div>Hello Everyone,<br><br></div>This is Gopesh Kumar Chaudhary from India.<br><br></div>I have couple of queries regarding mktime function.<br><br></div>e.g.<br><br></div>TZ=Europe/Berlin (Olson)<br><br>struct tm prnt_time;<br>        prnt_time.tm_wday = 0;<br>        prnt_time.tm_mon = 10 - 1;<br>        prnt_time.tm_mday = 30;<br>        prnt_time.tm_hour = 2;<br>        prnt_time.tm_min = 0;<br>        prnt_time.tm_sec = 0;<br>        prnt_time.tm_year = 116;<br>        prnt_time.tm_isdst = -1;<br><br><br></div>Above tm structure represent 30th OCT 2:30 2016 for Europe/Berlin in Olson .<br></div><br></div>For Europe/Berlin DST fallback will happen on 30th Oct at 3 , so clock will show 2 to 3 time period twice.<br><br>I have set the dst flag to -1 , for mktime to decide whether the given time in tm structure is DST time or non DST time.<br><br></div>Now coming to my query :<br>1) In above mentioned scenario  does mktime has the intelligence to decide whether above  mentioned time in tm structure is in DST or not as dst flag is set to -1 ?<br><br></div><div>2) I have a sample code <br><br>Sample code :-<br>-----------------------<br># cat gops.c<br>#include&lt;stdio.h&gt;<br>#include&lt;time.h&gt;<br><br>int main(int argc,char **argv){<br>        struct tm *at;<br>        time_t when,now;<br>        now=atoi(argv[1]);<br>        at=localtime(&amp;now);<br>        at-&gt;tm_isdst = -1;<br>        when=mktime(at);<br>        printf(&quot;now=%d when=%d\n&quot;,now,when);<br>        return 0;<br>}<br><br><br></div><div>OS: Linux (RHEL 7.2) <br></div><div>Platform:x86<br></div><div>TZ:Europe/Berlin (Olson)<br></div><div><br><br># ./gops 1477787940   ==============&gt;This epoch is for 2:39 30th Oct 2016 DST<br>now=1477787940 when=1477791540    ====&gt;Here mktime is giving me the epoch for   2:39 30th Oct 2016 non-DST <br><br><br># ./gops 1477791540 ==============&gt;This epoch is for 2:39 30th Oct 2016 non DST<br>now=1477791540  when=1477791540    ====&gt;Here mktime is giving me the epoch for   2:39 30th Oct 2016 non-DST <br>                               <wbr>                              <wbr>        <br></div><div><div>With the above example it can be seen that irrespective of the DST/non-DST window , it is always giving non DST epoch only ----<br><br></div><div>Is this standard behavior or is this bug in mktime ?<br><br><br></div><div>Thanks.<br><br></div><div>Regards,<br></div><div>Gopesh Kumar Chaudhary<br></div><div><br><br> </div></div></div>