Bug 6723

Summary: mktime() unexpected behaviour if tm_isdst > 1
Product: glibc Reporter: Michael Ringe <Michael.Ringe>
Component: libcAssignee: Ulrich Drepper <drepper.fsp>
Status: RESOLVED FIXED    
Severity: normal CC: glibc-bugs
Priority: P2 Flags: fweimer: security-
Version: unspecified   
Target Milestone: ---   
Host: Target: Linux/i686
Build: Last reconfirmed:

Description Michael Ringe 2008-07-06 17:52:37 UTC
According to the mktime() manual page, a positive value of tm_isdst means that
DST is in effect. However, mktime() seems to check only for tm_isdst==1, while
any other positive value is treated as "no DST".

Consider this program:
    int i;
    for (i = 1; i <= 2; ++i) {
        struct tm tm;
        memset(&tm,0,sizeof(tm));
        tm.tm_mday = 1;
        tm.tm_mon = 10;
        tm.tm_year = 108;
        tm.tm_isdst = i;
        printf("isdst=%d",tm.tm_isdst);
        time_t t = mktime(&tm);
        printf(" --> mktime()=%d isdst=%d\n",t,tm.tm_isdst);
    }

When running e.g. with TZ=Europe/Berlin, the output is

   isdst=1 --> mktime()=1225490400 isdst=0
   isdst=2 --> mktime()=1225494000 isdst=0

Of course, the time in question is non-DST, and mktime correctly changes
tm_isdst to 0. But IMHO there are two issues here:

1. The manpage should make clear wether or not the DST offset is
   applied in cases like this (take a look, for example, into the  
   Solaris manpage)
2. All positive values of tm_isdst should produce the same result
Comment 1 Ulrich Drepper 2008-07-06 21:19:02 UTC
I changed the libc code but the man pages are a completely separate project.