[tz] Regarding mktime issue

Gopesh Kumar Chaudhary kumar.ggopesh at gmail.com
Wed Mar 8 06:45:24 UTC 2017

Hello Everyone,

This is Gopesh Kumar Chaudhary from India.

I have couple of queries regarding mktime function.


TZ=Europe/Berlin (Olson)

struct tm prnt_time;
        prnt_time.tm_wday = 0;
        prnt_time.tm_mon = 10 - 1;
        prnt_time.tm_mday = 30;
        prnt_time.tm_hour = 2;
        prnt_time.tm_min = 0;
        prnt_time.tm_sec = 0;
        prnt_time.tm_year = 116;
        prnt_time.tm_isdst = -1;

Above tm structure represent 30th OCT 2:30 2016 for Europe/Berlin in Olson .

For Europe/Berlin DST fallback will happen on 30th Oct at 3 , so clock will
show 2 to 3 time period twice.

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.

Now coming to my query :
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 ?

2) I have a sample code

Sample code :-
# cat gops.c

int main(int argc,char **argv){
        struct tm *at;
        time_t when,now;
        at->tm_isdst = -1;
        printf("now=%d when=%d\n",now,when);
        return 0;

OS: Linux (RHEL 7.2)
TZ:Europe/Berlin (Olson)

# ./gops 1477787940   ==============>This epoch is for 2:39 30th Oct 2016
now=1477787940 when=1477791540    ====>Here mktime is giving me the epoch
for   2:39 30th Oct 2016 non-DST

# ./gops 1477791540 ==============>This epoch is for 2:39 30th Oct 2016 non
now=1477791540  when=1477791540    ====>Here mktime is giving me the epoch
for   2:39 30th Oct 2016 non-DST

With the above example it can be seen that irrespective of the DST/non-DST
window , it is always giving non DST epoch only ----

Is this standard behavior or is this bug in mktime ?


Gopesh Kumar Chaudhary
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mm.icann.org/pipermail/tz/attachments/20170308/fd750c9b/attachment.html>

More information about the tz mailing list